Guest User

Untitled

a guest
Feb 20th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 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 ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> inputDrivers = Console.ReadLine().Split(new char[] { ' ' }
  14. , StringSplitOptions
  15. .RemoveEmptyEntries)
  16. .ToList();
  17. List<double> zone = Console.ReadLine().Split(new char[] { ' ' }
  18. , StringSplitOptions
  19. .RemoveEmptyEntries)
  20. .Select(double.Parse)
  21. .ToList();
  22. List<long> index = Console.ReadLine().Split(new char[] { ' ' }
  23. , StringSplitOptions
  24. .RemoveEmptyEntries)
  25. .Select(long.Parse)
  26. .ToList();
  27.  
  28.  
  29. foreach (var nameDriver in inputDrivers)
  30. {
  31.  
  32. double fuel = nameDriver[0];
  33.  
  34. for (int i = 0; i < zone.Count; i++)
  35. {
  36. bool openZone = false;
  37.  
  38. if (index.Contains(i))
  39. {
  40. fuel += zone[i];
  41. openZone = true;
  42. }
  43.  
  44. if (openZone == false)
  45. {
  46. fuel -= zone[i];
  47. }
  48. if (fuel <= 0)
  49. {
  50. Console.WriteLine("{0} - reached {1}", nameDriver, i);
  51. goto startLine;
  52. }
  53. }
  54. Console.WriteLine("{0} - fuel left {1:f2}", nameDriver, fuel);
  55. startLine:
  56. continue;
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment