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 Bomb
- {
- class Program
- {
- static void Main(string[] args)
- {
- var myList = Console.ReadLine().Split().Select(int.Parse).ToList();
- int[] commands = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int specialNum = commands[0];
- int range = commands[1];
- for (int i = 0; i < myList.Count; i++)
- {
- if (myList[i]==specialNum)
- {
- if (i-range<0)
- {
- for (int x = 0; x < i; x++)
- {
- myList[x] = 0;
- }
- for (int y = i; y <= i + range; y++)
- {
- myList[y] = 0;
- }
- }
- else if (i+range > myList.Count-1)
- {
- for (int x = myList.Count-1; x >= i ; x--)
- {
- myList[x] = 0;
- }
- for (int y = i; y >= i - range; y--)
- {
- myList[y] = 0;
- }
- }
- else
- {
- myList.RemoveRange(i - range, range * 2 + 1);
- }
- }
- }
- int sum = myList.Sum();
- Console.WriteLine(sum);
- }
- }
- }
Add Comment
Please, Sign In to add comment