Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp76
- {
- class Program
- {
- static void Main(string[] args)
- {
- var result = new Dictionary<string, int>();
- var submissions = new Dictionary<string, int>();
- string command;
- while ((command = Console.ReadLine()) != "exam finished")
- {
- var splited = command.Split("-").ToList();
- string name = splited[0];
- string lenguage = splited[1];
- if (lenguage == "banned")
- {
- result.Remove(name);
- }
- else
- {
- var number = int.Parse(splited[2]);
- if (!result.ContainsKey(name))
- {
- result[name] = number;
- }
- else
- {
- if (result[name] < number)
- {
- result[name] += number;
- }
- }
- if (!submissions.ContainsKey(lenguage))
- {
- submissions[lenguage] = 0;
- }
- submissions[lenguage]++;
- }
- }
- Console.WriteLine("Results:");
- foreach (var kvp in result.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{kvp.Key} | {kvp.Value}");
- }
- Console.WriteLine("Submissons:");
- foreach (var kvp in submissions.OrderBy(x=>x.Key))
- {
- Console.WriteLine($"{kvp.Key} - {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement