Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _03.Concert;
- internal class Program
- {
- static void Main(string[] args)
- {
- string command;
- int totalTime = 0;
- Dictionary<string, int> bandTime = new();
- Dictionary<string, List<string>> bandMembers = new();
- while ( (command = Console.ReadLine()) != "Start!" )
- {
- string[] input = command.Split("; ", StringSplitOptions.RemoveEmptyEntries);
- string action = input[0];
- string band = input[1];
- if (action == "Add")
- {
- List<string> members = input[2].Split(", ").ToList();
- if (!bandMembers.ContainsKey(band))
- {
- bandMembers.Add(band, new List<string>());
- }
- for (int i = 0; i < members.Count; i++)
- {
- if (!bandMembers[band].Contains(members[i]))
- {
- bandMembers[band].Add(members[i]);
- }
- }
- }
- else if (action == "Play")
- {
- int time = int.Parse(input[2]);
- totalTime += time;
- if (!bandTime.ContainsKey(band))
- {
- bandTime.Add(band, time);
- }
- else
- {
- bandTime[band] += time;
- }
- }
- }
- Console.WriteLine($"Total time: {totalTime}");
- foreach (KeyValuePair<string, int> band in bandTime)
- {
- Console.WriteLine($"{band.Key} -> {band.Value}");
- }
- KeyValuePair<string, List<string>> firstBand = bandMembers.FirstOrDefault();
- if (firstBand.Key != null)
- {
- Console.WriteLine(firstBand.Key);
- Console.WriteLine("=> " + string.Join(Environment.NewLine + "=> ", firstBand.Value));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement