Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _04SoftUniExamResults
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> userPoints = new Dictionary<string, int>();
- Dictionary<string, int> examSubs = new Dictionary<string, int>();
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "exam finished")
- {
- break;
- }
- if (!command.Contains("banned"))
- {
- string[] tokens = command.Split("-");
- string username = tokens[0];
- string examName = tokens[1];
- int points = int.Parse(tokens[2]);
- if (!userPoints.ContainsKey(username))
- {
- userPoints.Add(username, points);
- }
- else
- {
- if (points>userPoints[username])
- {
- userPoints[username] = points;
- }
- }
- if (!examSubs.ContainsKey(examName))
- {
- examSubs.Add(examName, 1);
- }
- else
- {
- examSubs[examName] += 1;
- }
- }
- else
- {
- string[] tokens = command.Split("-");
- string username = tokens[0];
- if (userPoints.ContainsKey(username))
- {
- userPoints.Remove(username);
- }
- }
- }
- Console.WriteLine("Results:");
- foreach (var kvp in userPoints.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
- {
- string username = kvp.Key;
- int points = kvp.Value;
- Console.WriteLine($"{username} | {points}");
- }
- Console.WriteLine("Submissions:");
- foreach (var kvp in examSubs.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
- {
- string language = kvp.Key;
- int submissionsCount = kvp.Value;
- Console.WriteLine($"{language} - {submissionsCount}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement