Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Bomb_Numbers_Lits_Exercises
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> nums = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToList();
- int[] bombNum = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- // string[] splitedBombNum = bombNum.Split(" ");
- int specialNum = bombNum[0];
- int power = bombNum[1];
- while (nums.Contains(specialNum))
- {
- int index = nums.IndexOf(specialNum);
- if (index < power)
- {
- nums.RemoveRange(0, index);
- }
- else
- {
- nums.RemoveRange(index - power, power);
- }
- index = nums.IndexOf(specialNum);
- if (index + power + 1 < nums.Count)
- {
- nums.RemoveRange(index, power + 1);
- }
- else
- {
- nums.RemoveRange(index, nums.Count - index);
- }
- }
- Console.WriteLine(nums.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment