Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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<string, List<Worms>>();
- var isHere = new List<string>();
- 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 (!book.ContainsKey(team))
- {
- book[team] = new List<Worms>();
- }
- if (!isHere.Contains(name))
- {
- var total = new Worms
- {
- Name = name,
- Score = score
- };
- book[team].Add(total);
- 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++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement