Advertisement
Guest User

Untitled

a guest
Oct 15th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _07.Bomb_Numbers
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<int> field = Console.ReadLine()
  14. .Split(' ')
  15. .Select(int.Parse)
  16. .ToList();
  17. List<int> bomb = Console.ReadLine()
  18. .Split(' ')
  19. .Select(int.Parse)
  20. .ToList();
  21.  
  22.  
  23.  
  24. for (int i = 0; i < field.Count; i++)
  25. {
  26. if (field[i] == bomb[0])
  27. {
  28. int start = Math.Abs(i - bomb[1]);
  29. int end = Math.Abs(bomb[1] * 2 + 1);
  30. if (i > field.Count/2)
  31. {
  32. end = Math.Abs((field.Count - i ) + bomb[1]);
  33. field.RemoveRange(start, end);
  34. }
  35. else if (start <= 0)
  36. {
  37. field.RemoveRange(0, end);
  38. }
  39. else
  40. {
  41. field.RemoveRange(start, end);
  42. }
  43. }
  44. }
  45. //Console.WriteLine(String.Join(" ",field));
  46. Console.WriteLine(field.Sum());
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement