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 MainClass
- {
- public static void Main(string[] args)
- {
- List<int> timeOfcarRace = Console.ReadLine().Split().Select(int.Parse).ToList();
- double SumTimeLeftCar = 0;
- double SumTimeRightCar = 0;
- for (int i = 0; i < timeOfcarRace.Count/2; i++)
- {
- if (timeOfcarRace[i] != 0)
- {
- SumTimeLeftCar += timeOfcarRace[i];
- }
- else
- {
- double currentTimeLeft = SumTimeLeftCar;
- double timeToReduce = currentTimeLeft * 0.2;
- SumTimeLeftCar = SumTimeLeftCar - timeToReduce;
- }
- }
- for (int k = timeOfcarRace.Count - 1; k >= timeOfcarRace.Count/2+1; k--)
- {
- if (timeOfcarRace[k] != 0)
- {
- SumTimeRightCar += timeOfcarRace[k];
- }
- else
- {
- double currentTimeRight = SumTimeRightCar;
- double timeToReduce = currentTimeRight * 0.2;
- SumTimeRightCar = SumTimeRightCar - timeToReduce;
- }
- }
- if (SumTimeLeftCar < SumTimeRightCar)
- {
- Console.WriteLine($"The winner is left with total time: {SumTimeLeftCar}");
- }
- else if (SumTimeRightCar < SumTimeLeftCar)
- {
- Console.WriteLine($"The winner is right with total time: {SumTimeRightCar}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement