Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace SoftUniExamResults
- {
- class Program
- {
- static void Main(string[] args)
- {
- var usernamesPoints = new Dictionary<string,List< int>>();
- var languagesSubmissionsCount = new Dictionary<string, int>();
- string input = string.Empty;
- while((input=Console.ReadLine())!="exam finished")
- {
- string[] inputArray = input.Split('-');
- if (inputArray.Length == 3)
- {
- string username = inputArray[0];
- string language = inputArray[1];
- int points = int.Parse(inputArray[2]);
- if (usernamesPoints.ContainsKey(username)==false && languagesSubmissionsCount.ContainsKey(language)==false)
- {
- usernamesPoints[username] =new List<int>();
- usernamesPoints[username].Add(points);
- languagesSubmissionsCount[language] = 1;
- }
- else if(usernamesPoints.ContainsKey(username)==true && languagesSubmissionsCount.ContainsKey(language)==false)
- {
- usernamesPoints[username].Add(points);
- languagesSubmissionsCount[language] = 1;
- }
- else if(usernamesPoints.ContainsKey(username)==false && languagesSubmissionsCount.ContainsKey(language)==true)
- {
- usernamesPoints[username] = new List<int>();
- usernamesPoints[username].Add(points);
- languagesSubmissionsCount[language] += 1;
- }
- else if (usernamesPoints.ContainsKey(username) == true && languagesSubmissionsCount.ContainsKey(language)==true)
- {
- usernamesPoints[username].Add(points);
- languagesSubmissionsCount[language] += 1;
- }
- }
- if (inputArray.Length == 2)
- {
- string username = inputArray[0];
- inputArray[1] = "banned";
- foreach (var kvp in usernamesPoints)
- {
- if(kvp.Key==username)
- {
- usernamesPoints.Remove(username);
- break;
- }
- }
- }
- }
- Console.WriteLine("Results:");
- foreach (var kvp in usernamesPoints.OrderByDescending(x=>x.Value.Max()).ThenBy(x=>x.Key))
- {
- string username = kvp.Key;
- var listOfAllPointsPerUser = kvp.Value;
- int maxPoints = listOfAllPointsPerUser.Max();
- Console.WriteLine($"{username} | {maxPoints}");
- }
- Console.WriteLine("Submissions:");
- foreach (var kvp in languagesSubmissionsCount.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
- {
- Console.WriteLine($"{kvp.Key} - {kvp.Value}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment