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