Advertisement
jordan3900

Untitled

Aug 3rd, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.RoliTheCoder
  8. {
  9. class RoliTheCoder
  10. {
  11. static void Main(string[] args)
  12. {
  13. string line = Console.ReadLine();
  14. Dictionary<string, List<string>> eventData = new Dictionary<string, List<string>>();
  15. Dictionary<int, string> idCheck = new Dictionary<int, string>();
  16.  
  17. while (line != "Time for Code")
  18. {
  19. string[] tokens = line.Split();
  20. int id = int.Parse(tokens[0]);
  21.  
  22. if (tokens[1][0]=='#')
  23. {
  24. string evenName = tokens[1].Substring(1);
  25. string[] participants = tokens.Skip(2).ToArray();
  26.  
  27. if (!idCheck.ContainsKey(id))
  28. {
  29. idCheck[id] = evenName;
  30.  
  31. if (!eventData.ContainsKey(evenName))
  32. {
  33. eventData[evenName] = new List<string>();
  34. }
  35. foreach (var name in participants)
  36. {
  37. if (!eventData[evenName].Contains(name))
  38. {
  39. eventData[evenName].Add(name);
  40. }
  41. }
  42. }
  43. else if (idCheck[id] == evenName)
  44. {
  45. foreach (var name in participants)
  46. {
  47. if (!eventData[evenName].Contains(name))
  48. {
  49. eventData[evenName].Add(name);
  50. }
  51. }
  52. }
  53.  
  54. }
  55.  
  56. line = Console.ReadLine();
  57.  
  58. }
  59. foreach (var item in eventData.OrderByDescending(a=>a.Value.Count).ThenBy(a=>a.Key))
  60. {
  61. Console.WriteLine($"{item.Key} - {item.Value.Count}");
  62. foreach (var it in item.Value.OrderBy(a=>a))
  63. {
  64. Console.WriteLine(it);
  65. }
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement