Advertisement
whitestarrr

Untitled

Oct 24th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 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 RoilTheCoder
  8. {
  9. class Event
  10. {
  11. public long ID { get; set; }
  12. public string Name { get; set; }
  13. public List<string> participants { get; set; }
  14.  
  15. }
  16. class RoilTheCoder
  17. {
  18. static void Main(string[] args)
  19. {
  20. string input = Console.ReadLine().Trim();
  21. List<Event> events = new List<Event>();
  22. while (input != "Time for Code")
  23. {
  24. string[] line = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  25. if (line[1].Substring(0, 1) == "#")
  26. {
  27. long eventID = long.Parse(line[0]);
  28. if (eventID >= 0)
  29. {
  30. string eventName = line[1].Substring(1);
  31.  
  32. if (!events.Any(x => x.ID == eventID))
  33. {
  34. if (!events.Any(x => x.Name == eventName))
  35. {
  36. Event newEvent = new Event();
  37. newEvent.ID = eventID;
  38. newEvent.Name = eventName;
  39. newEvent.participants = new List<string>();a
  40. for (int i = 2; i < line.Length; i++)
  41. {
  42. newEvent.participants.Add(line[i]);
  43. }
  44. events.Add(newEvent);
  45. }
  46.  
  47. }
  48. else if (events.Any(x => x.ID == eventID))
  49. {
  50. var currentEvent = events.First(x => x.ID == eventID);
  51. if (currentEvent.Name == eventName)
  52. {
  53. for (int i = 2; i < line.Length; i++)
  54. {
  55. if (!currentEvent.participants.Contains(line[i]))
  56. {
  57. currentEvent.participants.Add(line[i]);
  58. }
  59. }
  60. }
  61. }
  62.  
  63. }
  64. }
  65. input = Console.ReadLine();
  66. }
  67.  
  68. var orderedEvents = events.OrderByDescending(x => x.participants.Count()).ThenBy(y => y.Name);
  69. foreach (var item in orderedEvents)
  70. {
  71. Console.WriteLine("{0} - {1}", item.Name, item.participants.Count());
  72. var orderedParticipants = item.participants.OrderBy(x => x);
  73. foreach (var participant in orderedParticipants)
  74. {
  75. Console.WriteLine("{0}", participant);
  76. }
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement