Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace BombNumbers
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- string command = Console.ReadLine();
- string[] commandArray = command.Split();
- int specialNumber = int.Parse(commandArray[0]);
- int power = int.Parse(commandArray[1]);
- while(numbers.Contains(specialNumber))
- {
- int bombIndex = numbers.IndexOf(specialNumber);
- int leftIndex = Math.Max(0, bombIndex - power);
- int rightIndex = Math.Min(numbers.Count - 1, bombIndex + power);
- numbers.RemoveRange(leftIndex, rightIndex - leftIndex + 1);
- }
- Console.WriteLine(numbers.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement