Advertisement
svetlyoek

Untitled

Mar 14th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp207
  6. {
  7. class Program
  8. {
  9.  
  10.  
  11. static void Main(string[] args)
  12. {
  13. string command = string.Empty;
  14. Dictionary<string,int> namesAndScores = new Dictionary<string, int>();
  15. Dictionary<string, int> techAndCounts = new Dictionary<string, int>();
  16.  
  17. while((command=Console.ReadLine())!="exam finished")
  18. {
  19. List<string> text = command.Split("-").ToList();
  20. if (text[1] == "banned"&&namesAndScores.ContainsKey(text[0]))
  21. {
  22. namesAndScores.Remove(text[0]);
  23. }
  24. else if (!namesAndScores.ContainsKey(text[0]) && !techAndCounts.ContainsKey(text[1])&&text[1]!="banned")
  25. {
  26. int number = int.Parse(text[2]);
  27. namesAndScores.Add(text[0], int.Parse(text[2]));
  28. if(number>namesAndScores[text[0]])
  29. {
  30. namesAndScores[text[0]] = number;
  31. }
  32. techAndCounts[text[1]] = 1 ;
  33. }
  34. else if(namesAndScores.ContainsKey(text[0]) && techAndCounts.ContainsKey(text[1])&&text[1]!="banned")
  35. {
  36.  
  37. techAndCounts[text[1]]++;
  38. }
  39.  
  40.  
  41. }
  42. Console.WriteLine("Results:");
  43. foreach(var item in namesAndScores.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
  44. {
  45. Console.WriteLine($"{item.Key} | {item.Value}");
  46. }
  47. Console.WriteLine("Submissions:");
  48. foreach(var item in techAndCounts.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
  49. {
  50. Console.WriteLine($"{item.Key} - {item.Value}");
  51. }
  52.  
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement