Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp76
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var result = new Dictionary<string, int>();
  12.  
  13. var submissions = new Dictionary<string, int>();
  14.  
  15. string command;
  16.  
  17. while ((command = Console.ReadLine()) != "exam finished")
  18. {
  19. var splited = command.Split("-").ToList();
  20.  
  21. string name = splited[0];
  22. string lenguage = splited[1];
  23.  
  24.  
  25. if (lenguage == "banned")
  26. {
  27. result.Remove(name);
  28. }
  29. else
  30. {
  31. var number = int.Parse(splited[2]);
  32.  
  33. if (!result.ContainsKey(name))
  34. {
  35. result[name] = number;
  36.  
  37.  
  38. }
  39. else
  40. {
  41. if (result[name] < number)
  42. {
  43. result[name] += number;
  44. }
  45. }
  46. if (!submissions.ContainsKey(lenguage))
  47. {
  48. submissions[lenguage] = 0;
  49. }
  50. submissions[lenguage]++;
  51. }
  52.  
  53.  
  54. }
  55. Console.WriteLine("Results:");
  56. foreach (var kvp in result.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  57. {
  58. Console.WriteLine($"{kvp.Key} | {kvp.Value}");
  59. }
  60.  
  61. Console.WriteLine("Submissons:");
  62. foreach (var kvp in submissions.OrderBy(x=>x.Key))
  63. {
  64. Console.WriteLine($"{kvp.Key} - {kvp.Value}");
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement