Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace P16.Ranking
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Ranking
- {
- public static void Main()
- {
- var contestsInformation = new Dictionary<string, string>();
- while (true)
- {
- var contestElements = Console.ReadLine().Split(':').ToList();
- if (contestElements[0] == "end of contests")
- {
- break;
- }
- else
- {
- var name = contestElements[0];
- var password = contestElements[1];
- contestsInformation[name] = password;
- }
- }
- var userInformation = new Dictionary<string, Dictionary<string, int>>();
- var bestCanditateName = string.Empty;
- var memoryPoints = 0;
- var bestCandidatePoints = 0;
- while (true)
- {
- var submissionElements = Console.ReadLine().Split("=>").ToList();
- if (submissionElements[0] == "end of submissions")
- {
- foreach (var kvp in userInformation)
- {
- foreach (var keyValuePair in kvp.Value)
- {
- bestCandidatePoints += keyValuePair.Value;
- }
- if (bestCandidatePoints > memoryPoints)
- {
- memoryPoints = bestCandidatePoints;
- bestCanditateName = kvp.Key;
- bestCandidatePoints = 0;
- }
- }
- Console.WriteLine($"Best candidate {bestCanditateName} with total {memoryPoints}.");
- break;
- }
- else
- {
- var language = submissionElements[0];
- var password = submissionElements[1];
- var username = submissionElements[2];
- var points = int.Parse(submissionElements[3]);
- if (contestsInformation.ContainsKey(language))
- {
- if (password == contestsInformation[language])
- {
- if (!userInformation.ContainsKey(username))
- {
- userInformation[username] = new Dictionary<string, int>();
- }
- if (!userInformation[username].ContainsKey(language))
- {
- userInformation[username][language] = 0;
- }
- if (points > userInformation[username][language])
- {
- userInformation[username][language] = points;
- }
- }
- }
- }
- }
- var resultDictionary = userInformation.OrderBy(k => k.Key).ThenByDescending(k => );
- foreach (var kvp in resultDictionary)
- {
- Console.WriteLine($"{kvp.Key}");
- foreach (var keyValuePair in kvp.Value)
- {
- Console.WriteLine($"# {keyValuePair.Key}->{keyValuePair.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement