Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P03MOBA_Challenger
- {
- class Program
- {
- static void Main(string[] args)
- {
- var playerPosAndSkill = new Dictionary<string, Dictionary<string, double>>();
- var playerAndSkill = new Dictionary<string, double>();
- while (true)
- {
- string end = Console.ReadLine();
- if (end == "Season end")
- {
- break;
- }
- if (end.Contains("->"))
- {
- List<string> input = end.Split(" -> ").ToList();
- string player = input[0];
- string position = input[1];
- double points = double.Parse(input[2]);
- if (!playerPosAndSkill.ContainsKey(player))
- {
- playerPosAndSkill[player] = new Dictionary<string, double>();
- playerPosAndSkill[player][position] = points;
- }
- else if (playerPosAndSkill[player].ContainsKey(position))
- {
- if (playerPosAndSkill[player][position] < points)
- {
- playerPosAndSkill[player][position] = points;
- }
- }
- else
- {
- playerPosAndSkill[player][position] = points;
- }
- if (!playerAndSkill.ContainsKey(player))
- {
- playerAndSkill[player] = points;
- }
- else
- {
- playerAndSkill[player] += points;
- }
- }
- else if (end.Contains("vs"))
- {
- List<string> input = end.Split(" vs ").ToList();
- string player1 = input[0];
- string player2 = input[1];
- if (playerPosAndSkill.ContainsKey(player1) && playerPosAndSkill.ContainsKey(player2))
- {
- foreach (var position1 in playerPosAndSkill[player1])
- {
- foreach (var position2 in playerPosAndSkill[player2])
- {
- if (position1.Key == position2.Key)
- {
- if (position1.Value > position2.Value)
- {
- playerPosAndSkill.Remove(player2);
- }
- else if (position1.Value < position2.Value)
- {
- playerPosAndSkill.Remove(player1);
- }
- }
- }
- }
- }
- }
- }
- int count = 0;
- foreach (var item in playerPosAndSkill.OrderByDescending(x => playerAndSkill[x.Key]))
- {
- int i = 0;
- // Console.WriteLine($"{playerAndSkill[item.Key]}: {playerAndSkill[item.Value.ToString()]} skills");
- // Console.WriteLine(item.Key);
- foreach (var sdf in playerAndSkill.OrderByDescending(x => x.Value).ThenBy(x=> x.Key))
- {
- if (count == i)
- {
- Console.WriteLine($"{sdf.Key}: {sdf.Value} skill");
- }
- i++;
- }
- foreach (var sdf in item.Value.OrderByDescending(x => x.Value).ThenBy(x=> x.Key))
- {
- Console.WriteLine($"- {sdf.Key} <::> {sdf.Value}");
- }
- count++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement