Advertisement
osman1997

MOBA Challenger

Jan 5th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Collections;
  6.  
  7. class Program
  8. {
  9.  
  10. static void Main()
  11. {
  12.  
  13. string command = Console.ReadLine();
  14.  
  15. Dictionary<string, Dictionary<string, int>> users = new Dictionary<string, Dictionary<string, int>>();
  16.  
  17.  
  18. while(command != "Season end")
  19. {
  20. if (command.Contains("->"))
  21. {
  22. string[] line = command.Split(" -> ");
  23. string name = line[0];
  24. string position = line[1];
  25. int points = int.Parse(line[2]);
  26.  
  27. if (!users.ContainsKey(name))
  28. {
  29. users.Add(name, new Dictionary<string, int>()
  30. {
  31. {position, points }
  32.  
  33. });
  34. }
  35. else
  36. {
  37. if (users.ContainsKey(name))
  38. {
  39. if (!users[name].ContainsKey(position))
  40. {
  41. users[name].Add(position, points);
  42. }
  43. else
  44. {
  45. if(users[name][position] < points)
  46. {
  47. users[name][position] = points;
  48. }
  49. }
  50. }
  51. }
  52. }
  53.  
  54. else
  55. {
  56. string[] line = command.Split(" vs ");
  57. string firstPlayer = line[0];
  58. string secondPlayer = line[1];
  59.  
  60. if(users.ContainsKey(firstPlayer) && users.ContainsKey(secondPlayer))
  61. {
  62. foreach (var first in users[firstPlayer])
  63. {
  64. foreach (var second in users[secondPlayer])
  65. {
  66. if(first.Key == second.Key)
  67. {
  68. if(users[firstPlayer].Values.Sum() > users[secondPlayer].Values.Sum())
  69. {
  70. users.Remove(secondPlayer);
  71. }
  72. else
  73. {
  74. users.Remove(firstPlayer);
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81.  
  82. command = Console.ReadLine();
  83. }
  84.  
  85. foreach (var item in users.OrderByDescending(s => s.Value.Values.Sum()).ThenBy(x => x.Key))
  86. {
  87.  
  88. int totalSkills = item.Value.Values.Sum();
  89. Console.WriteLine($"{item.Key}: {totalSkills} skill");
  90.  
  91. foreach (var kvp in item.Value.OrderByDescending(s => s.Value))
  92. {
  93. Console.WriteLine($"- {kvp.Key} <::> {kvp.Value}");
  94. }
  95. }
  96.  
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement