Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- Dictionary<string, Dictionary<string, int>> contestUserPoints = new
- Dictionary<string, Dictionary<string, int>>();
- Dictionary<string, int> individualStandings = new Dictionary<string, int>();
- string input;
- while ((input = Console.ReadLine()) != "no more time")
- {
- string[] inputArgs = input.Split(" -> ", StringSplitOptions.RemoveEmptyEntries);
- string username = inputArgs[0];
- string contest = inputArgs[1];
- int points = int.Parse(inputArgs[2]);
- if (!contestUserPoints.ContainsKey(contest))
- {
- contestUserPoints[contest] = new Dictionary<string, int>();
- }
- if (!contestUserPoints[contest].ContainsKey(username))
- {
- contestUserPoints[contest][username] = 0;
- }
- if (points > contestUserPoints[contest][username])
- {
- contestUserPoints[contest][username] = points;
- }
- if (!individualStandings.ContainsKey(username))
- {
- individualStandings[username] = 0;
- }
- individualStandings[username] += points;
- }
- foreach (var kvp in contestUserPoints)
- {
- Console.WriteLine($"{kvp.Key}: {kvp.Value.Count} participants");
- int counter = 0;
- var filteredDict = kvp.Value
- .OrderByDescending(x => x.Value)
- .ThenBy(x => x.Key)
- .ToDictionary(x => x.Key, x => x.Value);
- foreach (var pair in filteredDict)
- {
- counter++;
- Console.WriteLine($"{counter}. {pair.Key} <::> {pair.Value}");
- }
- }
- var orderIndividualStanding = individualStandings
- .OrderByDescending(x => x.Value)
- .ThenBy(x => x.Key)
- .ToDictionary(x => x.Key, x => x.Value);
- Console.WriteLine("Individual standings:");
- int counterSecond = 0;
- foreach (var kvp in orderIndividualStanding)
- {
- counterSecond++;
- Console.WriteLine($"{counterSecond}. {kvp.Key} -> {kvp.Value}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement