Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program {
- static void Main(string[] args) {
- List<int> input = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> power = Console.ReadLine().Split().Select(int.Parse).ToList();
- for (int i = 0; i < input.Count; i++)
- {
- if (input[i] == power[0])
- {
- for (int k = 0; k < power[1]; k++)
- {
- if (i - 1 >=0)
- {
- input.RemoveAt(i-1);
- i--;
- }
- }
- for (int k = 0; k < power[1]; k++)
- {
- if (i+1 < input.Count)
- {
- input.RemoveAt(i+1);
- }
- }
- input.RemoveAt(i);
- }
- }
- Console.WriteLine(input.Sum());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement