Advertisement
Guest User

Untitled

a guest
Dec 20th, 2021
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp8
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var userPoints = new Dictionary<string, int>();
  12.             var submissions = new Dictionary<string, int>();
  13.             var userData =
  14.                   new Dictionary<string, Dictionary<string, double>>();
  15.  
  16.             var input = Console.ReadLine();
  17.             while (input != "exam finished")
  18.             {
  19.                 var inputArgs = input.Split("-");
  20.  
  21.                 var user = inputArgs[0];
  22.                 var languageOrBan = inputArgs[1];
  23.                 if (languageOrBan == "banned")
  24.                 {
  25.                     userPoints.Remove(user);
  26.                     input = Console.ReadLine();
  27.                     continue;
  28.                 }
  29.                 var points = int.Parse(inputArgs[2]);
  30.                 if (!userPoints.ContainsKey(user))
  31.                 {
  32.                     userPoints[user] = 0;
  33.                 }
  34.                 userPoints[user] = Math.Max(userPoints[user], points);
  35.                 if (!submissions.ContainsKey(languageOrBan))
  36.                 {
  37.                     submissions[languageOrBan] = 0;
  38.                 }
  39.                 submissions[languageOrBan] += 1;
  40.                 input = Console.ReadLine();
  41.             }
  42.             Console.WriteLine("Results:");
  43.             foreach (var kvp in userPoints.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  44.             {
  45.                 Console.WriteLine(kvp.Key + " | " + kvp.Value);
  46.             }
  47.             Console.WriteLine("Submissions:");
  48.             foreach (var kvp in submissions.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  49.             {
  50.                 Console.WriteLine(kvp.Key + " - " + kvp.Value);
  51.             }
  52.         }
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement