Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace MOBAChallenger
- {
- class Program
- {
- static void Main(string[] args)
- {
- var allPlayers = new SortedDictionary<string, SortedDictionary<string, int>>();
- List<string> input = Console.ReadLine().Split(' ').ToList();
- while (input[0] != "Season")
- {
- if (input[1] == "vs")
- {
- string firstPlayer = input[0];
- string secondPlayer = input[2];
- if (allPlayers.ContainsKey(firstPlayer) && allPlayers.ContainsKey(secondPlayer) && (firstPlayer != secondPlayer))
- {
- bool defeated = false;
- foreach (var position1 in allPlayers[firstPlayer])
- {
- foreach (var position2 in allPlayers[secondPlayer])
- {
- if (position1.Key == position2.Key)
- {
- if (position1.Value > position2.Value)
- {
- allPlayers.Remove(secondPlayer);
- defeated = true;
- break;
- }
- else if (position2.Value > position1.Value)
- {
- allPlayers.Remove(firstPlayer);
- defeated = true;
- break;
- }
- }
- }
- if (defeated)
- {
- break;
- }
- }
- }
- }
- else
- {
- string player = input[0];
- string position = input[2];
- int skill = int.Parse(input[4]);
- var temporary = new SortedDictionary<string, int>();
- if (!allPlayers.ContainsKey(player))
- {
- temporary.Add(position, skill);
- allPlayers.Add(player, temporary);
- }
- else
- {
- if (!allPlayers[player].ContainsKey(position))
- {
- allPlayers[player].Add(position, skill);
- }
- else
- {
- if (allPlayers[player][position] < skill)
- {
- allPlayers[player][position] = skill;
- }
- }
- }
- }
- input = Console.ReadLine().Split(' ').ToList();
- }
- int totalSkill = 0;
- foreach (var item in allPlayers.OrderByDescending(x => x.Value.Values.Sum()))
- {
- totalSkill = item.Value.Values.Sum();
- Console.WriteLine($"{item.Key}: {totalSkill} skill");
- foreach (var pair in item.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"- {pair.Key} <::> {pair.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement