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;
- using System.Text.RegularExpressions;
- using System.Numerics;
- namespace LegendaryFarming
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- var regex = new Regex(@"([A-Z][a-z]+\s|[A-Z][a-z]+\s[A-Z][a-z]+\s)@\D+\s\d+\s\d+");
- var result = regex.IsMatch(input);
- Dictionary<string, Dictionary<string, BigInteger>> performancies = new Dictionary<string, Dictionary<string, BigInteger>>();
- while (input!= "End")
- {
- if (result==true)
- {
- var regexSinger = new Regex(@"([A-Z][a-z]+\s|[A-Z][a-z]+\s[A-Z][a-z]+\s)@");
- var singesr = regexSinger.Match(input);
- string singer = singesr.Value.ToString().TrimEnd('@').Trim();
- var regexTickets = new Regex(@"\s\d+\s");
- var price= regexTickets.Match(input);
- BigInteger ticketsPrice = BigInteger.Parse(price.Value.ToString().Trim());
- var regexTicketsCount = new Regex(@"\s\d+$");
- var count = regexTicketsCount.Match(input);
- BigInteger ticketsCount = BigInteger.Parse(count.Value.ToString().Trim());
- var regexVenue = new Regex(@"@[A-Z][a-z]+\D+");
- var ve = regexVenue.Match(input);
- string venue = ve.Value.ToString().TrimStart('@').Trim();
- if (!performancies.ContainsKey(venue))
- {
- performancies[venue] = new Dictionary<string, BigInteger>();
- if (!performancies[venue].ContainsKey(singer))
- {
- performancies[venue][singer] = ticketsCount * ticketsPrice;
- }
- else
- {
- performancies[venue][singer] += ticketsCount * ticketsPrice;
- }
- }
- else
- {
- if (!performancies[venue].ContainsKey(singer))
- {
- performancies[venue][singer] = ticketsCount * ticketsPrice;
- }
- else
- {
- performancies[venue][singer] += ticketsCount * ticketsPrice;
- }
- }
- }
- input = Console.ReadLine();
- regex = new Regex(@"([A-Z][a-z]+\s|[A-Z][a-z]+\s[A-Z][a-z]+\s)@\D+\s\d+\s\d+");
- result = regex.IsMatch(input);
- }
- foreach (var item in performancies)
- {
- Console.WriteLine($"{item.Key}");
- foreach (var singerANdMoney in item.Value.OrderByDescending(x=>x.Value))
- {
- Console.WriteLine($"# {singerANdMoney.Key} -> {singerANdMoney.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement