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