Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace SoftUniKaraoke
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> participants = Console.ReadLine().Split(", ").ToList();
- List<string> songs = Console.ReadLine().Split(", ").ToList();
- var info = new Dictionary<string, SortedSet<string>>();
- string command;
- while ((command = Console.ReadLine()) != "dawn")
- {
- string[] tokens = command.Split(", ");
- string participant = tokens[0], song = tokens[1], award = tokens[2];
- if (participants.Contains(participant) && songs.Contains(song))
- {
- if (!info.ContainsKey(participant))
- {
- info[participant] = new SortedSet<string>();
- }
- info[participant].Add(award);
- }
- }
- if (info.Count > 0)
- {
- foreach (var i in info.OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{i.Key}: {i.Value.Count} awards\n--" + String.Join("\n--", i.Value));
- }
- }
- else
- {
- Console.WriteLine("No awards");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement