Advertisement
Guest User

Untitled

a guest
Dec 31st, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 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.Trainers
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Dictionary<string, decimal> teamReg = new Dictionary<string, decimal>();
  14. teamReg["Theoretical"] = 0M;
  15. teamReg["Technical"] = 0M;
  16. teamReg["Practical"] = 0M;
  17.  
  18. // ТРЯБВА ЗАДЪЛЖИТЕЛНО да се зададе default подредени отбори
  19. // защото ако имаме за например ... тест
  20.  
  21. // ## Input
  22. //2
  23. //0
  24. //0
  25. //Technical
  26. //0
  27. //0
  28. //Practical
  29.  
  30. // Изхода който ще искаме ще бъде :
  31.  
  32. // ## Output
  33. // The Theoretical Trainers win with $0.000.
  34.  
  35. // Иначе тест №6 ще дава грещка защото ще иска изход с Theoretical Trainers като печелещия отбор
  36.  
  37. int numberOfParticipants = int.Parse(Console.ReadLine());
  38.  
  39. for (int i = 0; i < numberOfParticipants; i++)
  40. {
  41. decimal distanceInMeters = decimal.Parse(Console.ReadLine()) * 1600M;
  42. decimal cargoInKillograms = decimal.Parse(Console.ReadLine()) * 1000M;
  43. string typeOfTeam = Console.ReadLine();
  44.  
  45. decimal participantEarnedMoney =
  46. (cargoInKillograms * 1.5m) - (0.7m * distanceInMeters * 2.5m);
  47.  
  48. if (teamReg.ContainsKey(typeOfTeam))
  49. {
  50. teamReg[typeOfTeam] += participantEarnedMoney;
  51. }
  52. }
  53.  
  54. // Output
  55. var participant = teamReg.OrderByDescending(x => x.Value).First();
  56. Console.WriteLine($"The {participant.Key} Trainers win with ${participant.Value:F3}.");
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement