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.Numerics;
- using System.Text;
- using System.Threading.Tasks;
- namespace Exercise3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<double, int>> players = new Dictionary<string, Dictionary<double, int>>();
- string[] drivers = Console.ReadLine().Split(' ');
- double[] zones = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
- List<int> checkpoints = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- for (int a = 0; a < drivers.Length; a++)
- {
- double playerFuel = drivers[a].First();
- Dictionary<double, int> fuelAndPos = new Dictionary<double, int>();
- for (int c = 0; c < zones.Length; c++)
- {
- if (checkpoints.Contains(c))
- {
- playerFuel += zones[c];
- }
- else
- {
- playerFuel -= zones[c];
- if (playerFuel<=0)
- {
- fuelAndPos.Add(playerFuel, c);
- players.Add(drivers[a], fuelAndPos);
- break;
- }
- }
- }
- if (playerFuel>0)
- {
- fuelAndPos.Add(playerFuel, -1);
- players.Add(drivers[a], fuelAndPos);
- }
- }
- foreach (var driver in players)
- {
- if (driver.Value.Values.Contains(-1))
- {
- Console.WriteLine($"{driver.Key} - fuel left {driver.Value.Keys.Min():f2}");
- }
- else
- {
- Console.WriteLine($"{driver.Key} - reached {driver.Value.Values.Min()}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement