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;
- public class Startup
- {
- public static void Main()
- {
- string[] drivers = Console.ReadLine().Split();
- List<double> zones = Console.ReadLine().Split().Select(double.Parse).ToList();
- List<long> checkpoints = Console.ReadLine().Split().Select(long.Parse).ToList();
- for (int i = 0; i < drivers.Length; i++)
- {
- char driver = drivers[i][0];
- double sum = driver;
- for (int k = 0; k < zones.Count; k++)
- {
- double zone = zones[k];
- if (checkpoints.Any(x => x == zones.IndexOf(zone)))
- {
- sum += zone;
- }
- else
- {
- sum -= zone;
- }
- if (sum < 0)
- {
- break;
- }
- }
- if (sum > 0)
- {
- Console.WriteLine($"{drivers[i]} - fuel left {sum:f2}");
- }
- else
- {
- Console.WriteLine($"{drivers[i]} - reached 0");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement