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 _04.RoliTheCoder
- {
- class RoliTheCoder
- {
- static void Main(string[] args)
- {
- string line = Console.ReadLine();
- Dictionary<string, List<string>> eventData = new Dictionary<string, List<string>>();
- Dictionary<int, string> idCheck = new Dictionary<int, string>();
- while (line != "Time for Code")
- {
- string[] tokens = line.Split();
- int id = int.Parse(tokens[0]);
- if (tokens[1][0]=='#')
- {
- string evenName = tokens[1].Substring(1);
- string[] participants = tokens.Skip(2).ToArray();
- if (!idCheck.ContainsKey(id))
- {
- idCheck[id] = evenName;
- if (!eventData.ContainsKey(evenName))
- {
- eventData[evenName] = new List<string>();
- }
- foreach (var name in participants)
- {
- if (!eventData[evenName].Contains(name))
- {
- eventData[evenName].Add(name);
- }
- }
- }
- else if (idCheck[id] == evenName)
- {
- foreach (var name in participants)
- {
- if (!eventData[evenName].Contains(name))
- {
- eventData[evenName].Add(name);
- }
- }
- }
- }
- line = Console.ReadLine();
- }
- foreach (var item in eventData.OrderByDescending(a=>a.Value.Count).ThenBy(a=>a.Key))
- {
- Console.WriteLine($"{item.Key} - {item.Value.Count}");
- foreach (var it in item.Value.OrderBy(a=>a))
- {
- Console.WriteLine(it);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement