Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _5.Bomb_Numbers
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. List<int> nums = Console.ReadLine().Split().Select(int.Parse).ToList();
  12. List<int> bomb = Console.ReadLine().Split().Select(int.Parse).ToList();
  13. int numsLength = nums.Count;
  14. int index;
  15. while ((index = nums.FindIndex(x => x == bomb[0])) !=-1)
  16. {
  17. int leftMargin = index - bomb[1];
  18. if (leftMargin < 0) leftMargin = 0;
  19. int rightMargin = index + bomb[1];
  20. if (rightMargin > numsLength - 1) rightMargin = numsLength - 1;
  21. for (int i = leftMargin; i <= rightMargin; i++)
  22. {
  23. nums.RemoveAt(leftMargin);
  24. }
  25. }
  26. Console.WriteLine(nums.Sum());
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement