Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Edurance_Rally
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] draiversNames = Console.ReadLine().Split();
- double[] trackLayotZones = Console.ReadLine()
- .Split()
- .Select(double.Parse)
- .ToArray();
- int[] checkpoints = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- foreach (var name in draiversNames)
- {
- double fuel = name[0];
- for (int index = 0; index < trackLayotZones.Length; index++)
- {
- if (checkpoints.Contains(index))
- {
- fuel += trackLayotZones[index];
- }
- else
- {
- fuel -= trackLayotZones[index];
- }
- if (fuel < 1)
- {
- Console.WriteLine($"{name} - reached {index}");
- break;
- }
- }
- if (fuel > 0)
- {
- Console.WriteLine($"{name} - fuel left {fuel:F2}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement