Advertisement
Guest User

Untitled

a guest
Aug 9th, 2021
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Program {
  6. static void Main(string[] args) {
  7. List<int> input = Console.ReadLine().Split().Select(int.Parse).ToList();
  8.  
  9. List<int> power = Console.ReadLine().Split().Select(int.Parse).ToList();
  10.  
  11. for (int i = 0; i < input.Count; i++)
  12. {
  13. if (input[i] == power[0])
  14. {
  15. for (int k = 0; k < power[1]; k++)
  16. {
  17. if (i - 1 >=0)
  18. {
  19. input.RemoveAt(i-1);
  20. i--;
  21. }
  22. }
  23. for (int k = 0; k < power[1]; k++)
  24. {
  25. if (i+1 < input.Count)
  26. {
  27. input.RemoveAt(i+1);
  28. }
  29. }
  30. input.RemoveAt(i);
  31. }
  32. }
  33. Console.WriteLine(input.Sum());
  34. }
  35. }
  36.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement