Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- using System.Numerics;
- public class Program
- {
- public static void Main()
- {
- Dictionary<string, Dictionary<string,long>> regionTypeCount = new Dictionary<string, Dictionary<string,long>>();
- while(true)
- {
- string command = Console.ReadLine();
- if(command == "Count em all")
- {
- break;
- }
- string[] tokens = command.Split(new string[]{" -> "},StringSplitOptions.RemoveEmptyEntries);
- string name = tokens[0];
- string type = tokens[1];
- int count = int.Parse(tokens[2]);
- if(!regionTypeCount.ContainsKey(name))
- {
- regionTypeCount.Add(name, new Dictionary<string,long>());
- regionTypeCount[name].Add("Black",0);
- regionTypeCount[name].Add("Red",0);
- regionTypeCount[name].Add("Green",0);
- }
- regionTypeCount[name][type]+=count;
- if(regionTypeCount[name]["Green"]>=1000000)
- {
- regionTypeCount[name]["Red"]+=regionTypeCount[name]["Green"]/1000000;
- regionTypeCount[name]["Green"]%=1000000;
- }
- if(regionTypeCount[name]["Red"]>=1000000)
- {
- regionTypeCount[name]["Black"]+=regionTypeCount[name]["Red"]/1000000;
- regionTypeCount[name]["Red"]%=1000000;
- }
- }
- foreach(var kvp in regionTypeCount.OrderByDescending(x=>x.Value["Black"]).ThenBy(x=>x.Key.Length).ThenBy(x=>x.Key))
- {
- string regionName = kvp.Key;
- Console.WriteLine(regionName);
- foreach(var inner in kvp.Value.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
- {
- Console.WriteLine("-> {0} : {1}",inner.Key,inner.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement