View difference between Paste ID: BbsWTNAG and ESCCWmqu
SHOW: | | - or go back to the newest paste.
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
class Program
5
{
6
    static void Main()
7
    {
8
        List<int> seuqnce = Console.ReadLine().Split().Select(int.Parse).ToList();
9
10
        string[] intpit = Console.ReadLine().Split();
11
12
        int number = int.Parse(intpit[0]);
13
        int power = int.Parse(intpit[1]);
14
15
        for (int i = 0; i < seuqnce.Count; i++)
16
        {
17
            if (seuqnce[i] == number)
18
            {
19
                int left = Math.Max(i - power, 0);
20
21
                int right = Math.Min(i + power, seuqnce.Count - 1);
22
23
                int lenght = right - left + 1;
24
                seuqnce.RemoveRange(left, lenght);
25
                i = 0;
26
            }
27
        }
28
        Console.WriteLine(seuqnce.Sum());
29
    }
30
}