Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SRABSKO
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, long>> dict = new Dictionary<string, Dictionary<string, long>>();
- while (true)
- {
- string inputLine = Console.ReadLine();
- if (inputLine.Equals("End"))
- {
- break;
- }
- if (!inputLine.Contains("@"))
- {
- continue;
- }
- string[] singerArgs = inputLine.Split('@');
- string singerName = singerArgs[0].Trim();
- string[] concertArgs = singerArgs[1].Split(' ');
- if (concertArgs.Length < 3 || !singerArgs[0].EndsWith(" "))
- {
- continue;
- }
- int ticketsCount = 0;
- int ticketsPrice = 0;
- try
- {
- ticketsCount = int.Parse(concertArgs[concertArgs.Length - 1]);
- ticketsPrice = int.Parse(concertArgs[concertArgs.Length - 2]);
- }
- catch (Exception)
- {
- continue;
- }
- string venue = "";
- for (int i = 0; i < concertArgs.Length - 2; i++)
- {
- venue += concertArgs[i] + " ";
- }
- venue = venue.TrimEnd();
- if (!dict.ContainsKey(venue))
- {
- dict.Add(venue, new Dictionary<string, long>());
- }
- if (!dict[venue].ContainsKey(singerName))
- {
- dict[venue].Add(singerName, 0);
- }
- dict[venue][singerName] += (long)ticketsPrice * ticketsCount;
- }
- foreach (var venue in dict)
- {
- Console.WriteLine(venue.Key);
- foreach (var singer in dict[venue.Key].OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"# {singer.Key} -> {singer.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement