Advertisement
social1986

Untitled

Nov 4th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _03.EnduranceRally
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string[] names = Console.ReadLine().Split(' ').ToArray();
  12. decimal[] zones = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
  13. List<decimal> checkpoints = Console.ReadLine().Split(' ').Select(decimal.Parse).ToList();
  14. for (int i = 0; i < names.Length; i++)
  15. {
  16. string name = names[i];
  17. decimal startFuel = name[0];
  18. List<decimal> checky = new List<decimal>(checkpoints);
  19. for (int j = 0; j < zones.Length; j++)
  20. {
  21. if (checky.Count == 0)
  22. {
  23. startFuel -= zones[j];
  24. }
  25. else
  26. {
  27. if (checky.Contains(j))
  28. {
  29. startFuel += zones[j];
  30. }
  31. else
  32. {
  33. startFuel -= zones[j];
  34. }
  35. }
  36.  
  37. if (startFuel <= 0)
  38. {
  39. Console.WriteLine($"{names[i]} - reached {j}");
  40. break;
  41. }
  42. }
  43. if (startFuel > 0)
  44. {
  45. Console.WriteLine($"{names[i]} - fuel left {startFuel:f2}");
  46. }
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement