Advertisement
bullit3189

Cubic Assault

Jun 11th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Numerics;
  6.  
  7. public class Program
  8. {
  9. public static void Main()
  10. {
  11. Dictionary<string, Dictionary<string,long>> regionTypeCount = new Dictionary<string, Dictionary<string,long>>();
  12.  
  13. while(true)
  14. {
  15. string command = Console.ReadLine();
  16.  
  17. if(command == "Count em all")
  18. {
  19. break;
  20. }
  21.  
  22. string[] tokens = command.Split(new string[]{" -> "},StringSplitOptions.RemoveEmptyEntries);
  23. string name = tokens[0];
  24. string type = tokens[1];
  25. int count = int.Parse(tokens[2]);
  26.  
  27. if(!regionTypeCount.ContainsKey(name))
  28. {
  29. regionTypeCount.Add(name, new Dictionary<string,long>());
  30. regionTypeCount[name].Add("Black",0);
  31. regionTypeCount[name].Add("Red",0);
  32. regionTypeCount[name].Add("Green",0);
  33. }
  34.  
  35. regionTypeCount[name][type]+=count;
  36.  
  37. if(regionTypeCount[name]["Green"]>=1000000)
  38. {
  39. regionTypeCount[name]["Red"]+=regionTypeCount[name]["Green"]/1000000;
  40. regionTypeCount[name]["Green"]%=1000000;
  41. }
  42. if(regionTypeCount[name]["Red"]>=1000000)
  43. {
  44. regionTypeCount[name]["Black"]+=regionTypeCount[name]["Red"]/1000000;
  45. regionTypeCount[name]["Red"]%=1000000;
  46. }
  47. }
  48.  
  49. foreach(var kvp in regionTypeCount.OrderByDescending(x=>x.Value["Black"]).ThenBy(x=>x.Key.Length).ThenBy(x=>x.Key))
  50. {
  51. string regionName = kvp.Key;
  52.  
  53. Console.WriteLine(regionName);
  54.  
  55. foreach(var inner in kvp.Value.OrderByDescending(x=>x.Value).ThenBy(x=>x.Key))
  56. {
  57. Console.WriteLine("-> {0} : {1}",inner.Key,inner.Value);
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement