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 _10_SrabskoUnleashed
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- var folkersData = new Dictionary<string, Dictionary<string, long>>();
- GetFolkersData(folkersData, input);
- foreach (var venue in folkersData)
- {
- Console.WriteLine($"{venue.Key}");
- foreach (var singer in venue.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine("# {0} -> {1}", singer.Key, singer.Value);
- }
- }
- }
- private static void GetFolkersData(Dictionary<string, Dictionary<string, long>> folkersData, string input)
- {
- while (input != "End")
- {
- if (input.Contains('@'))
- {
- string[] singerName = input.Split('@');
- if (singerName[1].Split().Length >= 3)
- {
- string singer = singerName[0].Substring(0, singerName[0].Length - 1);
- List<string> checkerSingerName = singer.Split().ToList();
- if (checkerSingerName.Count <= 3)
- {
- List<string> venueAndTickets = singerName[1].Split().ToList();
- if (venueAndTickets.Count >= 3)
- {
- if (long.TryParse(venueAndTickets[venueAndTickets.Count - 1], out _)
- && long.TryParse(venueAndTickets[venueAndTickets.Count - 2], out _))
- {
- long ticketCount = long.Parse(venueAndTickets[venueAndTickets.Count - 1]);
- venueAndTickets.RemoveAt(venueAndTickets.Count - 1);
- long ticketPrice = long.Parse(venueAndTickets[venueAndTickets.Count - 1]);
- venueAndTickets.RemoveAt(venueAndTickets.Count - 1);
- long ticketMoney = ticketCount * ticketPrice;
- string venue = string.Join(" ", venueAndTickets);
- List<string> checkerVenueName = venue.Split().ToList();
- if (checkerVenueName.Count <= 3)
- {
- if (!folkersData.ContainsKey(venue))
- {
- folkersData[venue] = new Dictionary<string, long>();
- }
- if (!folkersData[venue].ContainsKey(singer))
- {
- folkersData[venue][singer] = ticketMoney;
- }
- else
- {
- folkersData[venue][singer] += ticketMoney;
- }
- }
- }
- }
- }
- }
- }
- input = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement