Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _10._Srabsko_Unleashed
- {
- class Program
- {
- static void Main(string[] args)
- {
- var srabskoList = new Dictionary<string, Dictionary<string, int>>();
- string line;
- while ((line = Console.ReadLine()) != "End")
- {
- string[] tokens = line
- .Split(" @");
- if (tokens.Length != 2)
- {
- continue;
- }
- string name = tokens[0];
- string[] temp = tokens[1]
- .Split();
- int tempLenght = temp.Length;
- if (tempLenght < 3)
- {
- continue;
- }
- int price = int.Parse(temp[tempLenght - 2]);
- int count = int.Parse(temp[tempLenght - 1]);
- string venues = string.Join(" ", temp.Take(tempLenght - 2));
- if (!srabskoList.ContainsKey(venues))
- {
- srabskoList.Add(venues, new Dictionary<string, int>());
- }
- if (!srabskoList[venues].ContainsKey(name))
- {
- srabskoList[venues][name] = price * count;
- }
- else
- {
- srabskoList[venues][name] += price * count;
- }
- }
- foreach (var srabskoPerTawn in srabskoList)
- {
- Console.WriteLine(srabskoPerTawn.Key);
- foreach (var singerPerPrice in srabskoPerTawn.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine("# " + singerPerPrice.Key + " -> " + singerPerPrice.Value);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement