Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace RoilTheCoder
- {
- class Event
- {
- public long ID { get; set; }
- public string Name { get; set; }
- public List<string> participants { get; set; }
- }
- class RoilTheCoder
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine().Trim();
- List<Event> events = new List<Event>();
- while (input != "Time for Code")
- {
- string[] line = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- if (line[1].Substring(0, 1) == "#")
- {
- long eventID = long.Parse(line[0]);
- if (eventID >= 0)
- {
- string eventName = line[1].Substring(1);
- if (!events.Any(x => x.ID == eventID))
- {
- if (!events.Any(x => x.Name == eventName))
- {
- Event newEvent = new Event();
- newEvent.ID = eventID;
- newEvent.Name = eventName;
- newEvent.participants = new List<string>();a
- for (int i = 2; i < line.Length; i++)
- {
- newEvent.participants.Add(line[i]);
- }
- events.Add(newEvent);
- }
- }
- else if (events.Any(x => x.ID == eventID))
- {
- var currentEvent = events.First(x => x.ID == eventID);
- if (currentEvent.Name == eventName)
- {
- for (int i = 2; i < line.Length; i++)
- {
- if (!currentEvent.participants.Contains(line[i]))
- {
- currentEvent.participants.Add(line[i]);
- }
- }
- }
- }
- }
- }
- input = Console.ReadLine();
- }
- var orderedEvents = events.OrderByDescending(x => x.participants.Count()).ThenBy(y => y.Name);
- foreach (var item in orderedEvents)
- {
- Console.WriteLine("{0} - {1}", item.Name, item.participants.Count());
- var orderedParticipants = item.participants.OrderBy(x => x);
- foreach (var participant in orderedParticipants)
- {
- Console.WriteLine("{0}", participant);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement