Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CarRace
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<double> time = Console.ReadLine().Split().Select(double.Parse).ToList();
- while(time.Count != 3)
- {
- double currentLeft = time[1];
- double currentRight = time[time.Count - 2];
- time[1] += time[0];
- time[1] *= currentLeft == 0 ? 0.8 : 1;
- time[time.Count - 2] += time[time.Count - 1];
- time[time.Count - 2] *= currentRight == 0 ? 0.8 : 1;
- time.RemoveAt(0);
- time.RemoveAt(time.Count - 1);
- }
- string winner = time[0] < time[2] ? "left" : "right";
- double total = time[0] < time[2] ? time[0] : time[2];
- Console.WriteLine($"The winner is {winner} with total time: {total}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement