using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Problem_4___Worms_World_Party { class Program { class Worms { public string Name { get; set; } public long Score { get; set; } } static void Main(string[] args) { var book = new Dictionary>(); var isHere = new List(); while (true) { var input = Console.ReadLine(); if (input == "quit") { break; } var currentWorm = input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries).ToArray(); var team = currentWorm[1]; var name = currentWorm[0]; var score = long.Parse(currentWorm[2]); if (!isHere.Contains(name)) { if (!book.ContainsKey(team)) { book[team] = new List(); } var total = new Worms { Name = name, Score = score }; book[team].Add(total); isHere.Add(name); } isHere.Add(name); } long count = 1; foreach (var item in book.OrderByDescending(a => a.Value.Sum(p => p.Score)) .ThenByDescending(a => a.Value.Sum(p => p.Score) / a.Value.Count())) { Console.WriteLine($"{count}. Team: {item.Key} - {item.Value.Sum(p => p.Score)}"); foreach (var item2 in item.Value.OrderByDescending(a => a.Score)) { Console.WriteLine($"###{item2.Name} : {item2.Score}"); } count++; } } } }