Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _07.PopulationCounter
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class PeopleInCountries
- {
- public static void Main()
- {
- var tokens = Console.ReadLine().Split('|');
- var countries = new Dictionary<string, Dictionary<string, long>>();
- while (tokens[0] != "report")
- {
- var countryName = tokens[1];
- if (!countries.ContainsKey(countryName))
- {
- countries[countryName] = new Dictionary<string, long>();
- }
- var cityName = tokens[0];
- var population = long.Parse(tokens[2]);
- countries[countryName][cityName] = population;
- tokens = Console.ReadLine().Split('|');
- }
- countries.OrderByDescending(x => x.Value.Select(y => y.Value).Sum()).ToDictionary(p => p.Key, p.key);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment