Advertisement
North_Point

01. Trainers

Aug 21st, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _01
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var count = int.Parse(Console.ReadLine());
  14.             var dic = new Dictionary<string, List<decimal>>();
  15.  
  16.             for (int i = 0; i < count; i++)
  17.             {
  18.                 var distance = decimal.Parse(Console.ReadLine());
  19.                 var cargo = decimal.Parse(Console.ReadLine());
  20.                 var team = Console.ReadLine();
  21.                 if (team == "Technical" || team == "Theoretical" || team == "Practical")
  22.                 {
  23.                     var milesToKm = distance * (decimal)1600;
  24.                     var kg = cargo * (decimal)1000;
  25.                     var kgPrice = Math.Round( kg * (decimal)1.5,3);
  26.                     var milesPrice = Math.Round((decimal)0.7 * milesToKm * (decimal)2.5,3);
  27.                     var participantEarnedMoney = (kgPrice - milesPrice);
  28.                     if (!dic.ContainsKey(team))
  29.                     {
  30.                         dic[team] = new List<decimal>();
  31.                     }
  32.                     dic[team].Add(participantEarnedMoney);
  33.                 }
  34.             }
  35.             foreach (var item in dic.OrderByDescending(x => x.Value.Sum()).Take(1))
  36.             {
  37.                 var sum = (decimal)0;
  38.                 foreach (var kvp in item.Value)
  39.                 {
  40.                     sum += (decimal)kvp;
  41.                 }
  42.                 var gosho = Math.Round(sum, 3); ;
  43.                 Console.WriteLine("The {0} Trainers win with ${1:f3}.",item.Key,sum);
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement