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.Numerics;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace Practice
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- var input = Console.ReadLine();
- var data = new Dictionary<string, Dictionary<string, int>>();
- var names = new List<string>();
- while (input != "quit")
- {
- var split = input.Split(new[] { '-', '>' }
- , StringSplitOptions.RemoveEmptyEntries);
- var name = split[0].Trim();
- var team = split[1].Trim();
- var score = int.Parse(split[2].Trim());
- if (names.Contains(name))
- {
- }
- else
- {
- names.Add(name);
- if (!data.ContainsKey(team))
- data[team] = new Dictionary<string, int>();
- data[team].Add(name, score);
- }
- input = Console.ReadLine();
- }
- var count = 1;
- var newdata = data
- .OrderByDescending(x => x.Value.Values.Sum())
- .ThenByDescending(x => x.Value.Values.Average());
- foreach (var team in newdata)
- {
- var sum = team.Value.Values.Sum();
- Console.WriteLine($"{count}. Team: {team.Key} - {sum}");
- foreach (var worm in team.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"###{worm.Key} : {worm.Value}");
- }
- count++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement