Advertisement
HristoGrigorov

bombNumbers

Jan 3rd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 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 _11.BombNumbers
  8. {
  9. class BombNumbers
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<decimal> numbers = Console.ReadLine().Split().Select(decimal.Parse).ToList();
  14. List<decimal> input = Console.ReadLine().Split().Select(decimal.Parse).ToList();
  15.  
  16. for (int i = 0; i < numbers.Count; i++)
  17. {
  18. if (input[0] == numbers[i])
  19. {
  20. for (int n = 0; n < input[1]; n++)
  21. {
  22.  
  23.  
  24. if (i < numbers.Count-1)
  25. {
  26. numbers.RemoveAt(i + 1);
  27. }
  28.  
  29.  
  30. if (i >= 1)
  31. {
  32. numbers.RemoveAt(i - 1);
  33. }
  34. if (i == 0)
  35. {
  36. continue;
  37. }
  38. else
  39. {
  40. i--;
  41. }
  42.  
  43. }
  44. numbers.RemoveAt(i);
  45. if (numbers.Contains(input[0]))
  46. {
  47. i = 0;
  48. }
  49. }
  50.  
  51. }
  52. Console.WriteLine(numbers.Sum());
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement