Advertisement
silvana1303

concert

Aug 8th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Text;
  6.  
  7. namespace _02._Boss_Rush
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.        
  14.             Dictionary<string, List<string>> team = new Dictionary<string, List<string>>();
  15.             Dictionary<string, int> time = new Dictionary<string, int>();
  16.        
  17.             string[] command = Console.ReadLine().Split("; ");
  18.      
  19.             int total = 0;
  20.  
  21.             while (command[0] != "start of concert")
  22.             {
  23.                 List<string> members = command[2].Split(", ").ToList();
  24.                 if (command[0] == "Add")
  25.                 {
  26.                     if (team.ContainsKey(command[1]))
  27.                     {
  28.                         for (int i = 0; i < members.Count; i++)
  29.                         {
  30.                            if (!team[command[1]].Contains(members[i]))
  31.                            {
  32.                               team[command[1]].Add(members[i]);
  33.                            }
  34.                            
  35.                         }
  36.                     }
  37.                     else
  38.                     {
  39.                         team[command[1]] = new List<string>();
  40.                         team[command[1]].AddRange(members);
  41.                        
  42.                     }
  43.                 }
  44.                 if (command[0] == "Play")
  45.                 {
  46.                     total += int.Parse(command[2]);
  47.                     if (time.ContainsKey(command[1]))
  48.                     {
  49.                         time[command[1]] += int.Parse(command[2]);
  50.                     }
  51.                     else
  52.                     {
  53.                         time[command[1]] = int.Parse(command[2]);
  54.            
  55.                     }
  56.                 }
  57.  
  58.                 command = Console.ReadLine().Split("; ");
  59.             }
  60.  
  61.             Console.WriteLine($"Total time: {total}");
  62.             foreach (var item in time.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  63.             {
  64.                 Console.WriteLine($"{item.Key} -> {item.Value}");
  65.             }
  66.  
  67.             string band = Console.ReadLine();
  68.             Console.WriteLine(band);
  69.             foreach (var item in team.Keys)
  70.             {
  71.                 if (item == band)
  72.                 {
  73.                     foreach (var member in team[item])
  74.                     {
  75.                         Console.WriteLine($"=> {member}");
  76.                     }
  77.                 }
  78.      
  79.             }
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement