Advertisement
fbinnzhivko

bomb numbers

Jun 8th, 2016
1,220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement