Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Ranking
- {
- class Program
- {
- public static void Main()
- {
- var contestsAndPasswords = new Dictionary<string, string>();
- var studentContests = new SortedDictionary<string, Dictionary<string, int>>();
- string command;
- while ((command = Console.ReadLine()) != "end of contests")
- {
- var current = command.Split(":");
- contestsAndPasswords.Add(current[0], current[1]);
- }
- while ((command = Console.ReadLine()) != "end of submissions")
- {
- var current = command.Split("=>");
- string contest = current[0];
- string password = current[1];
- string username = current[2];
- int points = int.Parse(current[3]);
- if (contestsAndPasswords.ContainsKey(contest) && contestsAndPasswords[contest] == password)
- {
- if (!studentContests.ContainsKey(username))
- {
- studentContests.Add(username, new Dictionary<string, int>());
- }
- if (!studentContests[username].ContainsKey(contest))
- {
- studentContests[username].Add(contest, points);
- }
- else
- {
- if (studentContests[username][contest] < points)
- {
- studentContests[username][contest] = points;
- }
- }
- }
- }
- string bestCandidate = "";
- int totalPoints = 0;
- foreach (var user in studentContests)
- {
- int userSum = user.Value.Sum(x => x.Value);
- if(userSum > totalPoints)
- {
- totalPoints = userSum;
- bestCandidate = user.Key;
- }
- }
- Console.WriteLine($"Best candidate is {bestCandidate} with total {totalPoints} points.\nRanking:");
- foreach (var student in studentContests)
- {
- Console.WriteLine(student.Key);
- foreach (var contest in student.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"# {contest.Key} -> {contest.Value}");
- }
- }
- }
- }
- }
Advertisement
Comments
-
- Name: Alex Hudson
- Discord:
- Radlic#2809
- Steam:
- https://steamcommunity.com/id/2528865
- Username | Passwords
- ---------------------------------------------
- walker3331 | jg0112; walker33
- Rad2809 | callum
- radleaf | eclipse4
- ---------------------------------------------
- Phones:
- (02) 6352 3590
- +61 263523590
- Home:
- 70 Calero St, Lithgow, NSW 2790, Australia.
- IP:
- 101.166.94.231
Add Comment
Please, Sign In to add comment
Advertisement