Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.Tracing;
- using System.Linq;
- using System.Runtime.InteropServices;
- namespace Judge
- {
- class Program
- {
- static void Main(string[] args)
- {
- var data = new Dictionary<string, Dictionary<string, int>>();
- var sumPoints = new Dictionary<string, int>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "no more time")
- {
- break;
- }
- string[] command = input.Split(" -> ").ToArray();
- string user = command[0];
- string contest = command[1];
- int points = int.Parse(command[2]);
- if (!data.ContainsKey(contest))
- {
- data.Add(contest, new Dictionary<string, int>());
- data[contest][user] = points;
- }
- else
- {
- if (!data[contest].ContainsKey(user))
- {
- data[contest][user] = points;
- }
- else
- {
- if (data[contest][user] < points)
- {
- data[contest][user] = points;
- }
- }
- }
- if (!sumPoints.ContainsKey(user))
- {
- sumPoints.Add(user, points);
- }
- else
- {
- if (sumPoints[user] < points)
- {
- sumPoints[user] = points;
- }
- else
- {
- sumPoints[user] += points;
- }
- }
- }
- foreach (var kvp in data)
- {
- Dictionary<string, int> nested2 = kvp.Value;
- Console.WriteLine($"{kvp.Key}: {kvp.Value.Count} participants");
- int counter = 1;
- foreach (var pair in nested2.OrderByDescending(p => p.Value).ThenBy(n => n.Key))
- {
- Console.WriteLine($"{counter++}. {pair.Key} <::> {pair.Value}");
- }
- }
- Console.WriteLine("Individual standings:");
- int count = 1;
- foreach (var mem in sumPoints.OrderByDescending(m => m.Value).ThenBy(c => c.Key))
- {
- Console.WriteLine($"{count++}. {mem.Key} -> {mem.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement