Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- namespace MOBAChallenger_Krassy
- {
- class Program
- {
- static void Main(string[] args)
- {
- string comand = "";
- Dictionary<string, Dictionary<string, int>> pool = new Dictionary<string, Dictionary<string, int>>();
- // bool isHaveSamePosition = false;
- while ((comand = Console.ReadLine()) != "Seаson end")
- {
- if (comand.Contains("->"))
- {
- string[] comandInArr = comand.Split(" -> ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- string player = comandInArr[0];
- string position = comandInArr[1];
- int skill = int.Parse(comandInArr[2]);
- if (!pool.ContainsKey(player))
- {
- pool.Add(player, new Dictionary<string, int>());
- pool[player].Add(position, skill);
- }
- else if (!pool[player].ContainsKey(position))
- {
- pool[player].Add(position, skill);
- }
- else if (pool[player].ContainsKey(position))
- {
- // pool[player][position] += skill;
- int MaxVelue = int.MinValue;
- if (MaxVelue <= skill)
- {
- MaxVelue = skill;
- pool[player][position] = MaxVelue;
- }
- }
- }
- else if (comand.Contains("vs"))
- {
- string[] comandInArr = comand.Split(" vs ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- string playerOne = comandInArr[0];
- string playerTwo = comandInArr[1];
- //if (!pool.ContainsKey(playerOne) || !pool.ContainsKey(playerTwo))
- //{
- // continue;
- //}
- //bool serchLestOneCommon = false;
- //foreach (var item in pool[playerOne])
- //{
- // if (pool[playerTwo].ContainsKey(item.Key))
- // {
- // serchLestOneCommon = true;
- // }
- //}
- if (pool.ContainsKey(playerOne) && pool.ContainsKey(playerTwo))
- {
- foreach (var info in pool[playerOne])
- {
- foreach (var inf in pool[playerTwo])
- {
- if (info.Key == inf.Key)
- {
- if (pool[playerOne].Values.Sum() > pool[playerTwo].Values.Sum())
- {
- pool.Remove(playerTwo);
- }
- else if (pool[playerOne].Values.Sum() < pool[playerTwo].Values.Sum())
- {
- pool.Remove(playerOne);
- }
- }
- }
- }
- }
- }
- else if (comand.Contains("end"))
- {
- break;
- }
- }
- //if (comand == "Season end")
- //{
- foreach (var info in pool.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{info.Key}: {info.Value.Values.Sum()} skill");
- foreach (var pair in info.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"- {pair.Key} <::> {pair.Value}");
- }
- }
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment