Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace MOBA_Challenger
- {
- class Program
- {
- static void Main(string[] args)
- { //start time 22:41 - solve 80% 00:36 (1:55h) ((celiq test 370/400 in 3:04h)
- SortedDictionary<string, Dictionary<string, int>> database = new SortedDictionary<string, Dictionary<string, int>>();
- Dictionary<string, int> totalSkill = new Dictionary<string, int>();
- string[] input = Console.ReadLine().Split().ToArray();
- string commandword = input[0] + " " + input[1];
- while (commandword != "Season end")
- {
- if (input[1] != "vs") // PULNIM
- {
- string player = input[0];
- string position = input[2];
- int skill = int.Parse(input[4]);
- if (database.ContainsKey(player) == false) // new player
- {
- database.Add(player, new Dictionary<string, int>());
- database[player].Add(position, skill);
- totalSkill.Add(player, skill);
- }
- else
- {
- if (database[player].ContainsKey(position) == false) // new position
- {
- database[player].Add(position, skill);
- totalSkill[player] += skill;
- }
- else //old position
- {
- int oldSKill = database[player][position];
- if (skill > oldSKill) //higher skill
- {
- database[player][position] = skill;
- int diff = skill - oldSKill;
- totalSkill[player] += diff;
- }
- }
- }
- }
- else //VERSUS
- {
- string player1 = input[0];
- string player2 = input[2];
- if (database.ContainsKey(player1))
- {
- int p1MMR = totalSkill[player1];
- int p2MMR = totalSkill[player2];
- foreach (var role in database[player1])
- {
- string p1role = role.Key;
- if (database.ContainsKey(player2))
- {
- foreach (var role2 in database[player2])
- {
- string p2role = role2.Key;
- if (p1role == p2role)
- {
- if (p1MMR > p2MMR)
- {
- database.Remove(player2);
- totalSkill.Remove(player2); break;
- }
- else if (p2MMR > p1MMR)
- {
- database.Remove(player1);
- totalSkill.Remove(player1); break;
- }
- }
- }
- }
- }
- }
- }
- input = Console.ReadLine().Split().ToArray();
- commandword = input[0] + " " + input[1];
- }
- //printing
- foreach (var entry in totalSkill.OrderBy(x => -x.Value))
- {
- string name = entry.Key;
- int totalMMR = entry.Value;
- Console.WriteLine($"{name}: {totalMMR} skill");
- foreach (var roleAndMMR in database[name].OrderBy(x => -x.Value))
- {
- string role = roleAndMMR.Key;
- int mmr = roleAndMMR.Value;
- Console.WriteLine($"- {role} <::> {mmr}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement