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 isMatch = regex.IsMatch(line);
- if (isMatch)
- {
- var splitted = line.Split('@');
- var venuePrices = splitted[1].Split();
- var name = splitted[0].Trim();
- var venue = "";
- for (int i = 0; i < venuePrices.Length - 2; i++)
- {
- venue += venuePrices[i] + " ";
- }
- venue = venue.Trim();
- var price = int.Parse(venuePrices[venuePrices.Length - 1].Trim());
- var count = int.Parse(venuePrices[venuePrices.Length - 2].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] += (price*count);
- }
- line = Console.ReadLine();
- }
- foreach (var city in events)
- {
- Console.WriteLine(city.Key);
- foreach (var performance in city.Value.OrderByDescending(t => t.Value))
- {
- Console.WriteLine("# {0} -> {1}", performance.Key, performance.Value);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement