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.Text.RegularExpressions;
- namespace _10Problem_SrubskoUnleashed
- {
- class Program
- {
- static void Main(string[] args)
- {
- string venues;
- string singerName;
- int ticketPrice;
- long ticketCount;
- long totalMoney;
- var placeAndSingers = new Dictionary<string, Dictionary<string, long>>();
- const string pattern = @"([a-zA-Z]+\s){1,3}@([a-zA-Z0-9]+\s){1,3}[0-9]+\s[0-9]+";
- string concertInfo = Console.ReadLine();
- while (concertInfo.Equals("End") == false)
- {
- var isTheInputValid = Regex.Match(concertInfo, pattern);
- if (isTheInputValid.Success)
- {
- string[] splitConcertInfo = concertInfo.Split('@');
- string[] rightPart = splitConcertInfo[1].Trim().Split();
- singerName = splitConcertInfo[0].Trim();
- venues = (rightPart[0]);
- if (rightPart.Length == 4)
- {
- venues += " " + rightPart[1];
- }
- ticketPrice = int.Parse(rightPart[rightPart.Length - 2]);
- ticketCount = long.Parse(rightPart[rightPart.Length - 1]);
- totalMoney = ticketPrice * ticketCount;
- if (placeAndSingers.ContainsKey(venues) == false)
- {
- placeAndSingers.Add(venues, new Dictionary<string, long>());
- placeAndSingers[venues].Add(singerName, totalMoney);
- }
- else
- {
- if (placeAndSingers[venues].ContainsKey(singerName) == false)
- {
- placeAndSingers[venues].Add(singerName, totalMoney);
- }
- else
- {
- placeAndSingers[venues][singerName] += totalMoney;
- }
- }
- }
- concertInfo = Console.ReadLine();
- }
- foreach (var place in placeAndSingers)
- {
- Console.WriteLine($"{place.Key}");
- foreach (var singerAndMoney in place.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"# {singerAndMoney.Key} -> {singerAndMoney.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement