Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 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.  
  8. namespace Edurance_Rally
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string[] draiversNames = Console.ReadLine().Split();
  15.  
  16. double[] trackLayotZones = Console.ReadLine()
  17. .Split()
  18. .Select(double.Parse)
  19. .ToArray();
  20.  
  21. int[] checkpoints = Console.ReadLine()
  22. .Split()
  23. .Select(int.Parse)
  24. .ToArray();
  25.  
  26. foreach (var name in draiversNames)
  27. {
  28. double fuel = name[0];
  29.  
  30. for (int index = 0; index < trackLayotZones.Length; index++)
  31. {
  32. if (checkpoints.Contains(index))
  33. {
  34. fuel += trackLayotZones[index];
  35. }
  36. else
  37. {
  38. fuel -= trackLayotZones[index];
  39. }
  40. if (fuel < 1)
  41. {
  42. Console.WriteLine($"{name} - reached {index}");
  43. break;
  44. }
  45. }
  46. if (fuel > 0)
  47. {
  48. Console.WriteLine($"{name} - fuel left {fuel:F2}");
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement