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.Collections;
- class Program
- {
- static void Main()
- {
- string command = Console.ReadLine();
- Dictionary<string, Dictionary<string, int>> users = new Dictionary<string, Dictionary<string, int>>();
- while(command != "Once upon a time")
- {
- string[] line = command.Split(" <:> ");
- string name = line[0];
- string color = line[1];
- int points = int.Parse(line[2]);
- if (!users.ContainsKey(name))
- {
- users.Add(name, new Dictionary<string, int>()
- {
- {color, points }
- });
- }
- else
- {
- if(users.ContainsKey(name) && !users[name].ContainsKey(color))
- {
- users[name].Add(color, points);
- }
- if(users.ContainsKey(name) && users[name].ContainsKey(color))
- {
- if(users[name][color] < points)
- {
- users[name][color] = points;
- }
- }
- }
- command = Console.ReadLine();
- }
- foreach (var item in users.OrderByDescending(s => s.Value.Values.Sum()).ThenByDescending(s => s.Value.Values.Count()))
- {
- foreach (var kvp in item.Value)
- {
- Console.WriteLine($"({kvp.Key}) {item.Key} <-> {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement