Advertisement
YavorGrancharov

Trainers(examTask01_80%)

Aug 20th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Trainers
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int n = int.Parse(Console.ReadLine());
  12.  
  13.             Dictionary<string, double> data = new Dictionary<string, double>();
  14.  
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 var distance = int.Parse(Console.ReadLine());
  18.                 var cargo = double.Parse(Console.ReadLine());
  19.                 string team = Console.ReadLine();
  20.  
  21.                 var miles = distance * 1600;
  22.                 var carried = cargo * 1000;
  23.                 var fuelExpences = (0.7 * miles) * 2.5;
  24.                 var cargoPrice = 1.5 * carried;
  25.                 var totalMoney = cargoPrice - fuelExpences;
  26.  
  27.                 if (team == "Technical" || team == "Theoretical" || team == "Practical")
  28.                 {
  29.                     if (!data.ContainsKey(team))
  30.                     {
  31.                         data[team] = totalMoney;
  32.                     }
  33.                 }              
  34.             }
  35.  
  36.             double maxValue = data.Max(x => x.Value);
  37.             foreach (var money in data.Where(x => x.Value == maxValue))
  38.             {
  39.                 Console.WriteLine("The {0} Trainers win with ${1:F3}.", money.Key, money.Value);
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement