Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace RoliTheCoder
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- var eventId = new Dictionary<int, string>();
- var eventParticipands = new Dictionary<string, HashSet<string>>();
- while (input != "Time for Code")
- {
- var info = input.Split(new char[] { ' ' },StringSplitOptions.RemoveEmptyEntries).ToList();
- if (info[1].StartsWith("#"))
- {
- var id = int.Parse(info[0]);
- string eventName = info[1].Substring(1);
- var participants = info.Skip(2).ToList();
- if (eventId.ContainsKey(id)==false)
- {
- eventId.Add(id, eventName);
- eventParticipands.Add(eventName, new HashSet<string>());
- }
- if (eventId.ContainsKey(id) && eventId[id]==eventName)
- {
- foreach (var participand in participants)
- {
- eventParticipands[eventName].Add(participand);
- }
- }
- }
- input = Console.ReadLine();
- }
- foreach (var eventName in eventParticipands.OrderByDescending(x=>x.Value.Count()).ThenBy(x=>x.Key))
- {
- Console.WriteLine($"{eventName.Key} - {eventName.Value.Count()}");
- foreach (var item in eventName.Value.OrderBy(x=>x))
- {
- Console.WriteLine(item);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment