Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _02._Judge
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
- Dictionary<string, int> dictMax = new Dictionary<string, int>();
- string comand = Console.ReadLine();
- while (comand != "no more time")
- {
- string[] info = comand.Split("->");
- string name = info[0];
- string contest = info[1];
- int poits = int.Parse(info[2]);
- if (!dict.ContainsKey(contest))
- {
- dict[contest] = new Dictionary<string, int>();
- }
- if (!dict[contest].ContainsKey(name))
- {
- dict[contest][name] = 0;
- }
- if (dict[contest][name] < poits)
- {
- dict[contest][name] = poits;
- }
- comand = Console.ReadLine();
- }
- foreach (var contest in dict)
- {
- Console.WriteLine($"{contest.Key}: {contest.Value.Count} participants");
- int count = 1;
- foreach (var item in contest.Value.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{count}. {item.Key}<::> {item.Value}");
- count++;
- }
- }
- Console.WriteLine($"Individual standings:");
- foreach (var item in dict)
- {
- foreach (var name in item.Value)
- {
- if (!dictMax.ContainsKey(name.Key))
- {
- dictMax[name.Key] = 0;
- }
- dictMax[name.Key] += name.Value;
- }
- }
- int countResult = 1;
- foreach (var item in dictMax.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{countResult}. {item.Key}-> {item.Value}");
- countResult++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment