Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] points = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToArray();
- int finIx = (points.Length / 2) + 1;
- double timeL = 0, timeR = 0;
- for (int i = 0; i < finIx - 1; i++) //left car
- {
- if (points[i] == 0)
- {
- timeL *= 0.8;
- }
- else
- {
- timeL += points[i];
- }
- }
- for (int i = points.Length - 1; i >= finIx; i--) //right car
- {
- if (points[i] == 0)
- {
- timeR *= 0.8;
- }
- else
- {
- timeR += points[i];
- }
- }
- string winner;
- double time = 0;
- if (timeL > timeR)
- {
- winner = "right";
- time = timeR;
- }
- else
- {
- winner = "left";
- time = timeL;
- }
- Console.WriteLine($"The winner is {winner} with total time: {time:#.#}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement