Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace Orders
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, List<string>> bands = new Dictionary<string, List<string>>();
- Dictionary<string, int> playTime = new Dictionary<string, int>();
- int total = 0;
- string input = string.Empty;
- while((input = Console.ReadLine()) != "start of concert")
- {
- string[] arrg = input.Split("; ").ToArray();
- string command = arrg[0];
- string names = arrg[1];
- if (command == "Add")
- {
- List<string> members = arrg[2].Split(", ").ToList();
- if (!bands.ContainsKey(names))
- {
- bands.Add(names, members);
- }
- else
- {
- foreach (var member in members)
- {
- if (!bands[names].Contains(member))
- {
- bands[names].Add(member);
- }
- }
- }
- }
- else
- {
- int time = int.Parse(arrg[2]);
- total += time;
- if (!playTime.ContainsKey(names))
- {
- playTime.Add(names, time);
- }
- else
- {
- playTime[names] += time;
- }
- }
- }
- string groupPlay = Console.ReadLine();
- //Console.WriteLine($"Total time: {total}");
- Console.WriteLine($"Total time: {playTime.Values.Sum()}");
- foreach (var band in playTime.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{band.Key} -> {band.Value}");
- }
- Console.WriteLine(groupPlay);
- foreach (var member in bands[groupPlay])
- {
- Console.WriteLine($"=> {member}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement