Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace mid_exam
- {
- class Program
- {
- static void Main(string[] args)
- {
- var command = Console.ReadLine().Split('-').ToArray();
- var results = new Dictionary<string, int>();
- var submissions = new Dictionary<string, int>();
- while (command[0] != "exam finished")
- {
- if (results.ContainsKey(command[0]) && command[1] != "banned")
- {
- if (int.Parse(command[2]) > results[command[0]])
- {
- results[command[0]] = int.Parse(command[2]);
- }
- }
- if ((!results.ContainsKey(command[0]) && command[1] != "banned"))
- {
- results[command[0]] = int.Parse(command[2]);
- }
- if (submissions.ContainsKey(command[1]))
- {
- submissions[command[1]]++;
- }
- else
- {
- submissions[command[1]] = 1;
- }
- if (command[1] == "banned")
- {
- results.Remove(command[0]);
- submissions.Remove(command[1]);
- }
- command = Console.ReadLine().Split('-').ToArray();
- }
- 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