Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         long traineeCount = long.Parse(Console.ReadLine());
  9.         Dictionary<string, decimal> result = new Dictionary<string, decimal>();
  10.         //result.Add("Technical", 0);
  11.         //result.Add("Practical", 0);
  12.         //result.Add("Theoretical", 0);
  13.  
  14.         for (int i = 0; i < traineeCount; i++)
  15.         {
  16.             long distanceInMiles = long.Parse(Console.ReadLine());
  17.             decimal cargoInTons = decimal.Parse(Console.ReadLine());
  18.             string teamName = Console.ReadLine();
  19.  
  20.             decimal profit = cargoInTons * 1000 * 1.5m - distanceInMiles * 1600 * 0.7m * 2.5m;
  21.  
  22.             if (!result.ContainsKey(teamName))
  23.             {
  24.                 result[teamName] = 0;
  25.             }
  26.             result[teamName] += profit;
  27.  
  28.         }
  29.         decimal winnerProfit = result.Values.Max();
  30.         string winnerTeam = result.FirstOrDefault(x => x.Value == winnerProfit).Key;
  31.  
  32.         Console.WriteLine($"The {winnerTeam} Trainers win with ${winnerProfit:F3}.");
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement