Guest User

Untitled

a guest
Oct 14th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace TestGround
  7. {
  8. class Test
  9. {
  10. static void Main(string[] args)
  11. {
  12. List<int> nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  13. int[] bombInfo = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. int bomb = bombInfo[0];
  15. int power = bombInfo[1];
  16.  
  17. while (nums.Contains(bomb))
  18. {
  19. int bombIndex = nums.IndexOf(bomb);
  20. int elementsOnRight = Math.Min(power, nums.Count - 1 - bombIndex);
  21. int elementsOnLeft = Math.Min(bombIndex, power);
  22. int startIndex = Math.Max(bombIndex - power, 0);
  23. nums.RemoveRange(startIndex, elementsOnLeft + 1 + elementsOnRight);
  24. }
  25. Console.WriteLine(nums.Sum());
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment