Advertisement
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 _5.Bomb_Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- var Num = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- var BombPower = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- var total = 0;
- var currPosition = 0;
- for (int i = 0; i < Num.Count; i++)
- {
- if (Num[i] == BombPower[0])
- {
- for (int leftSide = 0; leftSide < BombPower[1]; leftSide++)
- {
- if (leftSide == 0)
- {
- currPosition = i;
- }
- if (Num[0] == BombPower[0])
- {
- break;
- }
- Num.RemoveAt(currPosition - 1);
- currPosition--;
- }
- for (int rightSide = 0; rightSide < BombPower[1]; rightSide++)
- {
- if (Num[Num.Count - 1] == BombPower[0])
- {
- break;
- }
- Num.RemoveAt(currPosition + 1);
- }
- }
- }
- foreach (var number in Num)
- {
- if (number != BombPower[0])
- {
- total += number;
- }
- }
- Console.WriteLine(total);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement