Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace BombNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- string line = Console.ReadLine();
- int bomb = int.Parse(line.Split()[0]);
- int power = int.Parse(line.Split()[1]);
- while (numbers.Contains(bomb))
- {
- int bombIndex = numbers.IndexOf(bomb);
- int startIndex = bombIndex - power;
- if (startIndex < 0)
- {
- break;
- }
- if (bombIndex + power >= numbers.Count)
- {
- numbers.RemoveRange(startIndex, numbers.Count - startIndex);
- }
- else
- {
- int endIndex = bombIndex + power;
- int count = endIndex - startIndex + 1;
- numbers.RemoveRange(startIndex, count);
- }
- }
- Console.WriteLine(numbers.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement