Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. namespace _04._MOBA_Challenger
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. try
  13. {
  14. var tier = new Dictionary<string, Dictionary<string, int>>();
  15. int num = 0;
  16. string name = string.Empty;
  17. string position = string.Empty;
  18. int skill = 0;
  19.  
  20. while (true)
  21. {
  22. List<string> input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToList();
  23.  
  24.  
  25. if (input.Count == 2)
  26. {
  27. break;
  28. }
  29.  
  30. if (tier.ContainsKey(input[0]) && input[1] == "vs" && tier.ContainsKey(input[2]))
  31. {
  32. foreach (var player in tier[input[2]])
  33. {
  34. if (tier[input[0]].ContainsKey(player.Key))
  35. {
  36. if (tier[input[2]].Values.Sum() > tier[input[0]].Values.Sum())
  37. {
  38. tier.Remove(input[0]);
  39. }
  40. else
  41. {
  42. tier.Remove(input[2]);
  43. }
  44. }
  45. }
  46. }
  47. else if (input[1] != "vs")
  48. {
  49. name = input[0];
  50. position = input[1];
  51.  
  52. if (tier.ContainsKey(name) == false)
  53. {
  54. skill = int.Parse(input[2]);
  55.  
  56. tier.Add(name, new Dictionary<string, int> { { position, skill } });
  57. }
  58. else if (position != "vs")
  59. {
  60.  
  61. if (tier[name].ContainsKey(position) == false)
  62. {
  63. skill = int.Parse(input[2]);
  64. tier[name].Add(position, skill);
  65. }
  66. else if (tier[name][position] < int.Parse(input[2]))
  67. {
  68. tier[name][position] = skill;
  69. }
  70. }
  71. }
  72. }
  73.  
  74. foreach (var player in tier.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x))
  75. {
  76. Console.WriteLine($"{player.Key}: {player.Value.Values.Sum()} skill");
  77.  
  78. foreach (var status in player.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  79. {
  80. Console.WriteLine($"- {status.Key} <::> {status.Value}");
  81. }
  82. }
  83. }
  84. catch (KeyNotFoundException)
  85. {
  86.  
  87. Console.WriteLine("some");
  88. }
  89. }
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement