Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P02Judge
- {
- class Program
- {
- static void Main(string[] args)
- {
- var result = new Dictionary<string, Dictionary<string, double>>();
- var individualStandings = new Dictionary<string, double>();
- while (true)
- {
- string end = Console.ReadLine();
- if (end == "no more time")
- {
- break;
- }
- List<string> input = end.Split(" -> ").ToList();
- string name = input[0];
- string contest = input[1];
- double points = double.Parse(input[2]);
- if (!result.ContainsKey(contest))
- {
- result[contest] = new Dictionary<string, double>();
- result[contest][name] = points;
- }
- else if (result[contest].ContainsKey(name))
- {
- if (result[contest][name] < points)
- {
- result[contest][name] = points;
- }
- }
- else
- {
- result[contest][name] = points;
- }
- }
- foreach (var item in result)
- {
- int count = 1;
- Console.WriteLine($"{item.Key}: {item.Value.Count} participants");
- foreach (var kvp in item.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- if (!individualStandings.ContainsKey(kvp.Key))
- {
- individualStandings[kvp.Key] = kvp.Value;
- }
- else
- {
- individualStandings[kvp.Key] += kvp.Value;
- }
- Console.WriteLine($"{count++}. {kvp.Key} <::> {kvp.Value}");
- }
- }
- Console.WriteLine("Individual standings:");
- int i = 1;
- foreach (var item in individualStandings.OrderByDescending(x => x.Value).ThenBy(x=>x.Key))
- {
- Console.WriteLine($"{i++}. {item.Key} -> {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement