Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- public static void Main()
- {
- Dictionary<string, List<string>> concertInfo = new Dictionary<string, List<string>>();
- Dictionary<string, int> concertTime = new Dictionary<string, int>();
- int totalTime = 0;
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "start of concert")
- {
- break;
- }
- string[] tokens = input.Split("; ");
- if (tokens[0] == "Add")
- {
- string[] members = tokens[2].Split(", ");
- if (concertInfo.ContainsKey(tokens[1]) == false)
- {
- concertInfo[tokens[1]] = new List<string>();
- }
- for (int i = 0; i < members.Length; i++)
- {
- concertInfo[tokens[1]].Add(members[i]);
- }
- }
- else if (tokens[0] == "Play")
- {
- string nameBand = tokens[1];
- int time = int.Parse(tokens[2]);
- if (concertTime.ContainsKey(nameBand))
- {
- concertTime[nameBand] += time;
- totalTime += time;
- }
- else
- {
- concertTime[nameBand] = 0;
- concertTime[nameBand] += time;
- totalTime += time;
- }
- }
- }
- string filter = Console.ReadLine();
- Console.WriteLine($"Total time: {totalTime}");
- foreach (var item in concertTime.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
- {
- Console.WriteLine($"{item.Key} -> {item.Value}");
- }
- foreach (var kvp in concertInfo.Where(x=>x.Key == filter))
- {
- Console.WriteLine($"{kvp.Key}");
- foreach (var item in kvp.Value.Distinct())
- {
- Console.WriteLine($"=> {item}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement