Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _5.Bomb_Numbers
- {
- class Program
- {
- static void Main()
- {
- List<int> nums = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> bomb = Console.ReadLine().Split().Select(int.Parse).ToList();
- int numsLength = nums.Count;
- int index;
- while ((index = nums.FindIndex(x => x == bomb[0])) !=-1)
- {
- int leftMargin = index - bomb[1];
- if (leftMargin < 0) leftMargin = 0;
- int rightMargin = index + bomb[1];
- if (rightMargin > numsLength - 1) rightMargin = numsLength - 1;
- for (int i = leftMargin; i <= rightMargin; i++)
- {
- nums.RemoveAt(leftMargin);
- }
- }
- Console.WriteLine(nums.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement