05. Bomb Numbers
Здравейте,
изкарвам 50/100. Идеи как да поправя кода?
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bomb_Numbers
{
class Program
{
static void Main(string[] args)
{
List<int> seq = Console.ReadLine().Split().Select(int.Parse).ToList();
List<int> number = Console.ReadLine().Split().Select(int.Parse).ToList();
int bombNum = number[0];
int powerBomb = number[1];
int pos = 0;
for (int i = 0; i < seq.Count; i++)
{
if (seq[i] == bombNum)
{
pos = i;
for (int j = 0; j < powerBomb; j++)
{
if ((i <= seq.Count - 1)&&(pos+1 <= seq.Count-1))
{
seq.RemoveAt(pos + 1);
}
}
for (int j = 0; j < powerBomb; j++)
{
if (i - powerBomb >= 0)
{
seq.RemoveAt(pos - j - 1);
}
}
if (pos-powerBomb < 0)
{
Console.WriteLine(0);
return;
}else
seq.RemoveAt(pos - powerBomb);
}
}
int sum = 0;
for (int i = 0; i < seq.Count; i++)
{
sum += seq[i];
}
Console.WriteLine(sum);
}
}
}