Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace MOBAChallenger
- {
- class Program
- {
- public static void Main()
- {
- var players = new Dictionary<string, Dictionary<string, int>>();
- string command;
- while ((command = Console.ReadLine()) != "Season end")
- {
- var current = command.Split(command.Contains(" -> ") ? " -> " : " vs ");
- string player = current[0];
- if (current.Length == 3)
- {
- string position = current[1];
- int skill = int.Parse(current[2]);
- if (!players.ContainsKey(player))
- {
- players.Add(player, new Dictionary<string, int>());
- }
- if (!players[player].ContainsKey(position))
- {
- players[player].Add(position, skill);
- }
- if (players[player][position] < skill)
- {
- players[player][position] = skill;
- }
- }
- else
- {
- string secondPlayer = current[1];
- if (players.ContainsKey(player) && players.ContainsKey(secondPlayer))
- {
- var sameSkills = players[player].Keys
- .Concat(players[secondPlayer].Keys)
- .ToList();
- sameSkills.Distinct()
- .ToList()
- .ForEach(x => sameSkills.Remove(x));
- if (sameSkills.Count > 0)
- {
- if (players[player][sameSkills[0]] < players[secondPlayer][sameSkills[0]])
- {
- players.Remove(player);
- }
- else if (players[player][sameSkills[0]] > players[secondPlayer][sameSkills[0]])
- {
- players.Remove(secondPlayer);
- }
- }
- }
- }
- }
- foreach (var player in players.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{ player.Key}: {player.Value.Values.Sum()} skill");
- foreach (var skill in player.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"- {skill.Key} <::> {skill.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement