Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _02._Car_Race
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> time = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToList();
- decimal sumLeft = 0.0m;
- decimal sumRight = 0.0m;
- for (int i = 0; i < time.Count / 2; i++)
- {
- if (time[i] == 0)
- {
- sumLeft *= 0.8m;
- }
- else
- {
- sumLeft += time[i];
- }
- if (time[time.Count - i - 1] == 0)
- {
- sumRight *= 0.8m;
- }
- else
- {
- sumRight += time[time.Count - i - 1];
- }
- }
- if (sumLeft <= sumRight)
- {
- Console.WriteLine($"The winner is left with total time: {sumLeft:F1}");
- }
- else
- {
- Console.WriteLine($"The winner is right with total time: {sumRight:F1}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement