Advertisement
TeMePyT

Untitled

Jan 14th, 2019
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace MOBA_Challenger
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Dictionary<string, Dictionary<string, int>> Players = new Dictionary<string, Dictionary<string, int>>();            
  14.             while (true)
  15.             {
  16.                    string line = Console.ReadLine();
  17.                    string[] linesplit = line.Split(new char[] { ' ', '-', '>' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  18.            
  19.                 if (line == "Season end")
  20.                 {
  21.                     foreach (var p in Players.OrderByDescending(x => x.Value.Values.Sum()).ThenBy(y => y.Key))
  22.                     {
  23.                         Console.WriteLine($"{p.Key}: {p.Value.Values.Sum()} skill");
  24.                         foreach (var pos in p.Value.OrderByDescending(x => x.Value).ThenBy(y => y.Key)){
  25.                          
  26.                             Console.WriteLine($"- {pos.Key} <::> {pos.Value}");
  27.                         }
  28.                     }
  29.                     return;
  30.                 }
  31.                 if (linesplit.Length == 3 && !linesplit.Contains("vs"))
  32.                 {
  33.                     string PlayersName = linesplit[0];
  34.                     string position = linesplit[1];
  35.                     int skill = int.Parse(linesplit[2]);
  36.  
  37.                     if (!Players.ContainsKey(PlayersName))
  38.                     {
  39.                         Players.Add(PlayersName, new Dictionary<string, int>());
  40.                         Players[PlayersName].Add(position, skill);
  41.                     }
  42.                    
  43.                    
  44.                         if (Players[PlayersName].ContainsKey(position))
  45.                         {
  46.                             if (Players[PlayersName][position] < skill)
  47.                                 Players[PlayersName][position] = skill;
  48.                         }
  49.                         else
  50.                         {
  51.                             Players[linesplit[0]].Add(linesplit[1], skill);
  52.                         }
  53.                    
  54.                 }
  55.                 if (linesplit.Length == 3 && linesplit.Contains("vs"))
  56.                 {
  57.                     string firstplayer = linesplit[0];
  58.                     string secondplayer = linesplit[2];
  59.                     if (Players.ContainsKey(firstplayer) && Players.ContainsKey(secondplayer))
  60.                     {
  61.                         string[] firstplayerpositions = Players[firstplayer].Keys.ToArray();
  62.                         foreach (var pos2 in Players[secondplayer].Keys)
  63.                         {
  64.                             if (firstplayerpositions.Contains(pos2))
  65.                             {
  66.                                 int totalSkillsfp = Players[firstplayer].Values.Sum();
  67.                                 int totalSkillssp = Players[secondplayer].Values.Sum();
  68.                                 if (totalSkillsfp > totalSkillssp)
  69.                                 {
  70.                                     Players.Remove(secondplayer);
  71.                                     break;
  72.                                 }
  73.                                 if (totalSkillsfp < totalSkillssp)
  74.                                 {
  75.                                     Players.Remove(firstplayer);
  76.                                     break;
  77.                                 }
  78.  
  79.  
  80.                             }
  81.                         }
  82.                     }
  83.                 }
  84.  
  85.             }
  86.         }
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement