Advertisement
Rayk

Untitled

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