Advertisement
Guest User

Untitled

a guest
May 25th, 2018
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5.  
  6. namespace Snowwhite
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string input = Console.ReadLine();
  13. Dictionary<string, Dictionary<string, BigInteger>> dwarfs = new Dictionary<string, Dictionary<string, BigInteger>>();
  14.  
  15. while (input != "Once upon a time")
  16. {
  17. string[] splitedInput = input.Split(new string[] { " <:> " }, StringSplitOptions.None);
  18.  
  19. string dwarfName = splitedInput[0];
  20. string dwarfColor = splitedInput[1];
  21. BigInteger dwarfPhysics = BigInteger.Parse(splitedInput[2]);
  22.  
  23. if (dwarfs.ContainsKey(dwarfColor))
  24. {
  25. if (dwarfs[dwarfColor].ContainsKey(dwarfName))
  26. {
  27. if (dwarfs[dwarfColor][dwarfName] < dwarfPhysics) dwarfs[dwarfColor][dwarfName] = dwarfPhysics;
  28. }
  29. else
  30. {
  31. dwarfs[dwarfColor].Add(dwarfName, dwarfPhysics);
  32. }
  33. }
  34. else
  35. {
  36. Dictionary<string, BigInteger> tmp = new Dictionary<string, BigInteger>();
  37. tmp.Add(dwarfName, dwarfPhysics);
  38. dwarfs.Add(dwarfColor, tmp);
  39. }
  40.  
  41. input = Console.ReadLine();
  42. }
  43.  
  44.  
  45. foreach (var dwarfNamePower in dwarfs.OrderByDescending(x => x.Value.Values).ThenByDescending(x=>x.Value.Keys.Count()))
  46. {
  47. foreach (var item in dwarfNamePower.Value)
  48. {
  49. Console.WriteLine($"({dwarfNamePower.Key}) {item.Key} <-> {item.Value}");
  50. }
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement