Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- List<int> timeCar = Console.ReadLine().
- Split().
- Select(int.Parse).
- ToList();
- double timeRightCar = 0;
- double timeLeftCar = 0;
- WinnerCar(timeCar, timeRightCar, timeLeftCar);
- }
- private static void WinnerCar(List<int> timeCar, double timeRightCar, double timeLeftCar)
- {
- timeLeftCar = LeftCar(timeCar, timeLeftCar);
- timeRightCar = RightCar(timeCar, timeRightCar);
- if (timeLeftCar < timeRightCar)
- {
- Console.WriteLine($"The winner is left with total time: {timeLeftCar}");
- }
- else
- {
- Console.WriteLine($"The winner is right with total time: {timeRightCar}");
- }
- }
- private static double RightCar(List<int> timeCar, double timeRightCar)
- {
- for (int i = timeCar.Count - 1; i > timeCar.Count / 2; i--)
- {
- if (timeCar[i] == 0)
- {
- timeRightCar *= 0.8;
- }
- else
- {
- timeRightCar += timeCar[i];
- }
- }
- return timeRightCar;
- }
- private static double LeftCar(List<int> timeCar, double timeLeftCar)
- {
- for (int i = 0; i < timeCar.Count / 2; i++)
- {
- if (timeCar[i] == 0)
- {
- timeLeftCar *= 0.8;
- }
- else
- {
- timeLeftCar += timeCar[i];
- }
- }
- return timeLeftCar;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement