Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Judge
- {
- class Program
- {
- public static void Main()
- {
- var contests = new Dictionary<string, Dictionary<string, int>>();
- var individualStanding = new Dictionary<string, int>();
- string command;
- while ((command = Console.ReadLine()) != "no more time")
- {
- var current = command.Split(" -> ");
- string user = current[0];
- string contest = current[1];
- int points = int.Parse(current[2]);
- if (!contests.ContainsKey(contest))
- {
- contests.Add(contest, new Dictionary<string, int>());
- }
- if (!contests[contest].ContainsKey(user))
- {
- contests[contest].Add(user, points);
- }
- if (contests[contest][user] < points)
- {
- contests[contest][user] = points;
- }
- }
- foreach (var contest in contests)
- {
- int index = 1;
- Console.WriteLine($"{contest.Key}: {contest.Value.Count} participants");
- foreach (var user in contest.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{index}. {user.Key} <::> {user.Value}");
- if (!individualStanding.ContainsKey(user.Key))
- {
- individualStanding.Add(user.Key, 0);
- }
- individualStanding[user.Key] += user.Value;
- index++;
- }
- }
- int position = 1;
- Console.WriteLine("Individual standings:");
- foreach (var user in individualStanding.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{position}. {user.Key} -> {user.Value}");
- position++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement