Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _EnduranceRally_ExPrepI
- {
- class Program
- {
- static void Main()
- {
- string[] drivers = Console.ReadLine().Split();
- double[] zones = Console.ReadLine().Split().Select(double.Parse).ToArray();
- int[] checkPoints = Console.ReadLine().Split().Select(int.Parse).ToArray();
- for (int i = 0; i < drivers.Length; i++)
- {
- string name = drivers[i];
- double fuel = name[0];
- int endPosition = 0;
- double zoneValue;
- for (int index = 0; index < zones.Length; index++)
- {
- zoneValue = zones[index];
- if (checkPoints.Contains(index))
- {
- fuel += zoneValue;
- }
- else
- {
- fuel -= zoneValue;
- }
- if (fuel <= 0)
- {
- endPosition = index;
- break;
- }
- }
- if (fuel > 0)
- {
- Console.WriteLine($"{name} - fuel left {fuel:f2}");
- }
- else
- {
- Console.WriteLine($"{name} - reached {endPosition}");
- }
- }
- }
- }
- } // 100 %
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement