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