Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace M04._Snowwhite
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dwarfColorNamePhyssics = new Dictionary<string, Dictionary<string, uint>>();
- string input = string.Empty;
- while ((input = Console.ReadLine()) != "Once upon a time")
- {
- string[] inputAsArray = input.Split(" <:> ");
- string name = inputAsArray[0];
- string color = inputAsArray[1];
- uint physics = uint.Parse(inputAsArray[2]);
- if (!dwarfColorNamePhyssics.ContainsKey(color))
- {
- dwarfColorNamePhyssics.Add(color, new Dictionary<string, uint>());
- dwarfColorNamePhyssics[color][name] = physics;
- }
- else if (dwarfColorNamePhyssics.ContainsKey(color) && !dwarfColorNamePhyssics[color].ContainsKey(name))
- {
- dwarfColorNamePhyssics[color][name] = physics;
- }
- else if (dwarfColorNamePhyssics.ContainsKey(color) && dwarfColorNamePhyssics[color].ContainsKey(name))
- {
- dwarfColorNamePhyssics[color][name] = Math.Max(dwarfColorNamePhyssics[color][name], physics);
- }
- }
- foreach (var kvp in dwarfColorNamePhyssics
- .OrderByDescending(x => x.Value.Values.First()).ThenByDescending(x => x.Value.Count()))
- {
- foreach (var item in kvp.Value.OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"({kvp.Key}) {item.Key} <-> {item.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement