Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Exe16BombNumbers
- {
- public class Exe16BombNumbers
- {
- public static void Main()
- {
- List<int> nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- int[] bomb = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- while (true)
- {
- if (nums.Contains(bomb[0]))
- {
- int index = nums.IndexOf(bomb[0]);
- int indBeg = 0;
- if ((index - bomb[1]) > 0)
- {
- indBeg = index - bomb[1];
- }
- int indEnd = (nums.Count - 1);
- if ((index + bomb[1]) < (nums.Count - 1))
- {
- indEnd = index + bomb[1];
- }
- for (int i = indBeg; i <= indEnd; i++)
- {
- nums.RemoveAt(indBeg);
- }
- }
- if (!nums.Contains(bomb[0]))
- break;
- }
- Console.WriteLine(nums.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement