-
Notifications
You must be signed in to change notification settings - Fork 0
/
01.Trainers.cs
58 lines (50 loc) · 1.98 KB
/
01.Trainers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
namespace _01.Task
{
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
long n = long.Parse(Console.ReadLine());
decimal techicalTrainersSum = 0;
decimal theoreticalTrainersSum = 0;
decimal practcalTrainersSum = 0;
for (int i = 0; i < n; i++)
{
long distanceInMeters = long.Parse(Console.ReadLine()) * 1600;
decimal cargoInKilograms = decimal.Parse(Console.ReadLine()) * 1000;
string teamName = Console.ReadLine();
decimal cargoIncome = 1.5m * cargoInKilograms;
decimal fuelConsumption = 0.7m * distanceInMeters * 2.5m;
decimal participantEarnedMoney = cargoIncome - fuelConsumption;
if (teamName == "Technical")
{
techicalTrainersSum += participantEarnedMoney;
}
else if (teamName == "Practical")
{
practcalTrainersSum += participantEarnedMoney;
}
else if (teamName == "Theoretical")
{
theoreticalTrainersSum += participantEarnedMoney;
}
}
decimal winTeamSum = Math.Max(theoreticalTrainersSum, Math.Max(techicalTrainersSum, practcalTrainersSum));
if (winTeamSum == theoreticalTrainersSum)
{
Console.WriteLine($"The Theoretical Trainers win with ${theoreticalTrainersSum:F3}.");
}
else if (winTeamSum == techicalTrainersSum)
{
Console.WriteLine($"The Technical Trainers win with ${techicalTrainersSum:F3}.");
}
else if (winTeamSum == practcalTrainersSum)
{
Console.WriteLine($"The Practical Trainers win with ${practcalTrainersSum:F3}.");
}
}
}
}