Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _04._MOBA_Challenger
- {
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- var tier = new Dictionary<string, Dictionary<string, int>>();
- int num = 0;
- string name = string.Empty;
- string position = string.Empty;
- int skill = 0;
- while (true)
- {
- List<string> input = Console.ReadLine().Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- if (input.Count == 2)
- {
- break;
- }
- if (tier.ContainsKey(input[0]) && input[1] == "vs" && tier.ContainsKey(input[2]))
- {
- foreach (var player in tier[input[2]])
- {
- if (tier[input[0]].ContainsKey(player.Key))
- {
- if (tier[input[2]].Values.Sum() > tier[input[0]].Values.Sum())
- {
- tier.Remove(input[0]);
- }
- else
- {
- tier.Remove(input[2]);
- }
- }
- }
- }
- else if (input[1] != "vs")
- {
- name = input[0];
- position = input[1];
- if (tier.ContainsKey(name) == false)
- {
- skill = int.Parse(input[2]);
- tier.Add(name, new Dictionary<string, int> { { position, skill } });
- }
- else if (position != "vs")
- {
- if (tier[name].ContainsKey(position) == false)
- {
- skill = int.Parse(input[2]);
- tier[name].Add(position, skill);
- }
- else if (tier[name][position] < int.Parse(input[2]))
- {
- tier[name][position] = skill;
- }
- }
- }
- }
- foreach (var player in tier.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x))
- {
- Console.WriteLine($"{player.Key}: {player.Value.Values.Sum()} skill");
- foreach (var status in player.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"- {status.Key} <::> {status.Value}");
- }
- }
- }
- catch (KeyNotFoundException)
- {
- Console.WriteLine("some");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement