Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04._International_SoftUniada
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<string, Dictionary<string, int>> result = new Dictionary<string, Dictionary<string, int>>();
- while (input !="END")
- {
- string[] line = input.Split(" -> ");
- string counrty = line[0];
- string name = line[1];
- int point = int.Parse(line[2]);
- if (!result.ContainsKey(counrty))
- {
- result.Add(counrty, new Dictionary<string, int>());
- result[counrty].Add(name, point);
- }
- else if (result.ContainsKey(counrty))
- {
- if (!result[counrty].ContainsKey(name))
- {
- result[counrty].Add(name, point);
- }
- else if (result[counrty].ContainsKey(name))
- {
- result[counrty][name] += point;
- }
- }
- input = Console.ReadLine();
- }
- foreach (var item in result.OrderByDescending(x=>x.Value.Values.Sum()))
- {
- Console.WriteLine($"{item.Key}: {item.Value.Values.Sum()}");
- foreach (var kvp in item.Value)
- {
- Console.WriteLine($" -- {kvp.Key} -> {kvp.Value}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement