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 SrabskoUnlesashed
- {
- using System.Text.RegularExpressions;
- class Program
- {
- static void Main(string[] args)
- {
- //Regex regex = new Regex(@"[\D]+[ ][@](.*?)*[ ][\d]+[ ][\d]+");
- var line = Console.ReadLine();
- var events = new Dictionary<string, Dictionary<string, int>>();
- while (line != "End")
- {
- var splitted = line.Split('@');
- var name = splitted[0];
- if (name[name.Length - 1] != ' ')
- {
- line = Console.ReadLine();
- continue;
- }
- Stack<string> venuePrices = new Stack<string>(splitted[1].Split());
- if (venuePrices.Count < 3)
- {
- line = Console.ReadLine();
- continue;
- }
- int ticketPrice = 0;
- int ticketCount = 0;
- try
- {
- ticketPrice = int.Parse(venuePrices.Pop().Trim());
- ticketCount = int.Parse(venuePrices.Pop().Trim());
- }
- catch (Exception e)
- {
- line = Console.ReadLine();
- continue;
- }
- var venue = string.Join(" ", venuePrices.Reverse()).Trim();
- if (!events.ContainsKey(venue))
- {
- events.Add(venue, new Dictionary<string, int>());
- }
- if (!events[venue].ContainsKey(name))
- {
- events[venue].Add(name, 0);
- }
- events[venue][name] += (ticketPrice * ticketCount);
- line = Console.ReadLine();
- }
- foreach (var city in events)
- {
- Console.WriteLine(city.Key.Trim());
- foreach (var performance in city.Value.OrderByDescending(t => t.Value))
- {
- Console.WriteLine("# {0} -> {1}", performance.Key.Trim(), performance.Value);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement