Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace СръбскоUnleashed
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, int>> venueSingerIncome = new Dictionary<string, Dictionary<string, int>>();
- string[] input = new string[2];
- string venue = "";
- string singer = "";
- int ticketPrice = 0;
- int ticketCount = 0;
- int totalIncome = 0;
- while (input[0] != "End")
- {
- input = Console.ReadLine().Split('@').ToArray();
- try
- {
- singer = input[0];
- List<string> theRest = input[1].Split(' ').ToList();
- ticketCount = int.Parse(theRest[theRest.Count - 1]);
- theRest.RemoveAt(theRest.Count - 1);
- ticketPrice = int.Parse(theRest[theRest.Count - 1]);
- theRest.RemoveAt(theRest.Count - 1);
- totalIncome = ticketCount * ticketPrice;
- venue = string.Join(" ", theRest);
- }
- catch (Exception)
- {
- continue;
- }
- if (!venueSingerIncome.ContainsKey(venue))
- {
- Dictionary<string, int> singerIncome = new Dictionary<string, int>();
- singerIncome.Add(singer, totalIncome);
- venueSingerIncome.Add(venue, singerIncome);
- }
- else
- {
- if (!venueSingerIncome[venue].ContainsKey(singer))
- {
- venueSingerIncome[venue].Add(singer, totalIncome);
- }
- else
- {
- venueSingerIncome[venue][singer] += totalIncome;
- }
- }
- }
- foreach (var pair in venueSingerIncome)
- {
- Console.WriteLine(pair.Key);
- foreach (var kvp in pair.Value.OrderByDescending(x=>x.Value))
- {
- Console.WriteLine($"# {kvp.Key}-> {kvp.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement