Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _12.Bomb_Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- var numbers = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
- int[] commands = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- int specialNumber = commands[0];
- int offset = numbers.IndexOf(specialNumber);
- int power = commands[1];
- while (numbers.IndexOf(specialNumber) == -1)
- {
- int startIndex = Math.Max(0, offset - power);
- int countToRemove = Math.Min(power*2 + 1, Math.Abs(numbers.Count - startIndex));
- numbers.RemoveRange(startIndex, countToRemove);
- offset = numbers.IndexOf(specialNumber);
- }
- Console.WriteLine(numbers.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement