Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
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 Endurance_Rally
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] driversNames = Console.ReadLine().Split();
  14. double[] zones = Console.ReadLine().Split().Select(double.Parse).ToArray();
  15. double[] checkpoints = Console.ReadLine().Split().Select(double.Parse).ToArray();
  16.  
  17. foreach (var driver in driversNames)
  18. {
  19. double fuel = (int)driver[0];
  20. int counter = 0;
  21.  
  22. for (int i = 0; i < zones.Length; i++)
  23. {
  24. bool equal = false;
  25. for (int j = 0; j < checkpoints.Length; j++)
  26. {
  27. if (i == checkpoints[j])
  28. {
  29. equal = true;
  30. break;
  31. }
  32. }
  33. if (equal)
  34. {
  35. fuel += zones[i];
  36. }
  37. else
  38. {
  39. fuel -= zones[i];
  40. }
  41.  
  42. if (fuel > 0)
  43. {
  44. counter++;
  45. }
  46. else
  47. {
  48. Console.WriteLine($"{driver} - reached {counter}");
  49. break;
  50. }
  51. }
  52. if (fuel > 0)
  53. {
  54. Console.WriteLine($"{driver} - fuel left {fuel:f2}");
  55. }
  56. }
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement