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.RegularExpressions;
- class SrubskoUnleashed
- {
- static void Main()
- {
- Dictionary<string, Dictionary<string, long>> database = new Dictionary<string, Dictionary<string, long>>();
- while (true)
- {
- string line = Console.ReadLine();
- if (line == "End")
- {
- break;
- }
- string pattern = @"(([a-zA-Z\s*]+)\s+(@[a-zA-Z\s*]+)\s+(\d+)\s+(\d+))";
- MatchCollection matches = Regex.Matches(line, pattern);
- foreach (Match match in matches)
- {
- if (match.Groups[1].Success)
- {
- string singer = match.Groups[2].Value;
- string venue = match.Groups[3].Value.Remove(0, 1);
- long ticketPrice = long.Parse(match.Groups[4].Value);
- long ticketsCount = long.Parse(match.Groups[5].Value);
- if (!database.ContainsKey(venue))
- {
- database.Add(venue, new Dictionary<string, long>());
- }
- if (!database[venue].ContainsKey(singer))
- {
- database[venue].Add(singer, 0L);
- }
- database[venue][singer] += ticketsCount * ticketPrice;
- }
- }
- }
- foreach (KeyValuePair<string, Dictionary<string, long>> pair in database)
- {
- Console.WriteLine("{0}", pair.Key);
- var sortedDict = from entry in pair.Value orderby entry.Value descending select entry;
- foreach (var entry in sortedDict)
- {
- Console.WriteLine("# {0} -> {1}", entry.Key, entry.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement