Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _05BombNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> combination = Console.ReadLine().Split().Select(int.Parse).ToList();
- int bombNumber = combination[0];
- int power = combination[1];
- int index = numbers.IndexOf(bombNumber);
- while (index != -1)
- {
- int startIndex = Math.Max(0, index - power);
- int count = Math.Min(power * 2 + 1, numbers.Count - startIndex);
- numbers.RemoveRange(startIndex, count);
- index = numbers.IndexOf(bombNumber);
- }
- Console.WriteLine(numbers.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment