Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Snowwhite
- {
- class Program
- {
- public static void Main()
- {
- var dwarfs = new Dictionary<string, int>();
- string command;
- while ((command = Console.ReadLine()) != "Once upon a time")
- {
- var dwarf = command.Split(" <:> ");
- string nameAndColor = dwarf[0] + '|' + dwarf[1];
- int physics = int.Parse(dwarf[2]);
- if (!dwarfs.ContainsKey(nameAndColor))
- {
- dwarfs.Add(nameAndColor, physics);
- }
- dwarfs[nameAndColor] = Math.Max(dwarfs[nameAndColor], physics);
- }
- foreach (var dwarf in dwarfs
- .OrderByDescending(x => x.Value)
- .ThenByDescending(x => dwarfs.Where(c => c.Key.Split('|')[1] == x.Key.Split('|')[1])
- .Count()))
- {
- Console.WriteLine($"({dwarf.Key.Split('|')[1]}) {dwarf.Key.Split('|')[0]} <-> {dwarf.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement