Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using System.Globalization;
  8.  
  9. namespace ExamPreparation2
  10. {
  11. public class Program
  12. {
  13. public static void Main()
  14. {
  15. var drivers = Console.ReadLine().Split().ToArray();
  16. var zones = Console.ReadLine().Split().Select(double.Parse).ToArray();
  17. var checkPoints = Console.ReadLine().Split().Select(double.Parse).ToArray();
  18. foreach (var driver in drivers)
  19. {
  20. double fuel = driver[0];
  21. for (int i = 0; i < zones.Length; i++)
  22. {
  23. var index = i;
  24. if(checkPoints.Contains(index))
  25. {
  26. foreach (var item in checkPoints)
  27. {
  28. if (index == item)
  29. {
  30. fuel += zones[i];
  31. }
  32. }
  33. }
  34. else
  35. {
  36. fuel -= zones[i];
  37. if (fuel <= 0)
  38. {
  39. Console.WriteLine("{0} - reached {1}",driver,i);
  40. }
  41. }
  42. }
  43. Console.WriteLine("{0} - fuel left {1:f2}",driver,fuel);
  44. }
  45.  
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement