#C13747. Filter Cities by Population
Filter Cities by Population
Filter Cities by Population
You are given a list of cities with their respective populations. Your task is to filter out the cities that have a population strictly greater than a given threshold. The program will read the input from standard input and output the result to standard output.
Input Format:
1. The first line contains an integer n denoting the number of cities.
2. The next n lines each contain a city's name (a single word without spaces) and its population (an integer), separated by a space.
3. The last line contains an integer representing the population threshold.
Output Format:
Output a JSON object (dictionary) where the keys are the names of the cities that have a population greater than the threshold, and the values are their corresponding populations.
Note: A city is included in the output only if its population is strictly greater than the threshold.
inputFormat
- The first line of the input is an integer n, representing the number of cities.
- Each of the following n lines contains the city name and its population separated by a space.
- The last line contains an integer threshold.
outputFormat
- Output a JSON object (dictionary) where each key is a city name and its value is the population, including only those cities with population strictly greater than the threshold.
3
New_York 8419000
Los_Angeles 3980400
Chicago 2716000
3000000
{"New_York": 8419000, "Los_Angeles": 3980400}