Guest User

Untitled

a guest
Oct 6th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace PokemonDontGo
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<long> input = Console.ReadLine().Split().Select(long.Parse).ToList();
  12. // List<long> input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Select(long.Parse).ToList();
  13.  
  14. //int index = int.Parse(Console.ReadLine());
  15. long sum = (long)0;
  16.  
  17. while (input.Count > 0)
  18. {
  19.  
  20. long number = (long)0;
  21. int index = int.Parse(Console.ReadLine());
  22.  
  23.  
  24. if (index > input.Count() - 1)
  25. {
  26. number = input.Last();
  27. sum += (long)number;
  28. input[input.Count - 1] = input[0];
  29. }
  30. else if (index < 0)
  31. {
  32. number = input[0];
  33. sum += (long)number;
  34. input[0] = input[input.Count - 1];
  35.  
  36.  
  37. }
  38.  
  39. else
  40. {
  41. number = input[index];
  42. sum += (long)number;
  43. input.RemoveAt(index);
  44. }
  45.  
  46. for (int i = 0; i < input.Count; i++)
  47. {
  48. if (input[i] <= index)
  49. {
  50. input[i] += number;
  51. }
  52. else
  53. {
  54. input[i] -= number;
  55. }
  56. }
  57. //index = int.Parse(Console.ReadLine());
  58. }
  59. Console.WriteLine(sum);
  60. }
  61.  
  62. }
  63. }
  64.  
Add Comment
Please, Sign In to add comment