Advertisement
Guest User

01. Trainers

a guest
Nov 3rd, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Security.Cryptography.X509Certificates;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace _01.Trainers
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. int n = int.Parse(Console.ReadLine());
  16.  
  17. var teamAndMoney = new Dictionary<string, decimal>();
  18.  
  19. for (int i = 0; i < n; i++)
  20. {
  21. var distance = long.Parse(Console.ReadLine());
  22. var cargo = long.Parse(Console.ReadLine());
  23. string team = Console.ReadLine();
  24. distance = distance * 1600;
  25. cargo = cargo * 1000;
  26. var money = (cargo * 1.5M) - (0.7M * distance * 2.5M);
  27. if (teamAndMoney.ContainsKey(team))
  28. {
  29. teamAndMoney[team] += money;
  30. }
  31. else
  32. {
  33. teamAndMoney.Add(team, money);
  34. }
  35. }
  36.  
  37. var winner = teamAndMoney.OrderByDescending(x => x.Value).FirstOrDefault();
  38. // var mostmoney = teamAndMoney.FirstOrDefault(x => x.Value == teamAndMoney.Values.Max()).Key;
  39. Console.WriteLine($"The {winner.Key} Trainers win with ${winner.Value:F3}.");
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement