#K46327. City Temperature Analyzer
City Temperature Analyzer
City Temperature Analyzer
In this problem, you are given a list of temperature readings from various cities on different dates. Each reading is represented by a date, a city name, and a temperature value. Note that if multiple readings are recorded for the same city on the same date, only the highest reading for that day should be considered. Your task is to compute the highest temperature recorded for each city across all dates.
More formally, for each city, let \(S_{city} = \{T_{i} : (d, city, T_{i}) \text{ is a reading and } T_{i} \text{ is the maximum among readings with date } d\}\). You need to output the maximum value in \(S_{city}\) for each city.
Input will be given via standard input (stdin) and your result should be output to standard output (stdout) in the form of a Python dictionary string. The order of keys in the dictionary does not matter.
inputFormat
The first line contains an integer \(n\) representing the number of temperature readings.
The next \(n\) lines each contain a reading in the following format:
date city temperature
Here, date
is a string (e.g., "2023-01-01"), city
is a string (e.g., "New_York"), and temperature
is an integer.
outputFormat
Output a dictionary in Python's dict string format where each key is a city name and the corresponding value is the highest temperature recorded for that city. The output should be printed in one line.
## sample7
2023-01-01 New_York 5
2023-01-02 New_York 10
2023-01-01 Los_Angeles 15
2023-01-02 Los_Angeles 20
2023-01-01 New_York -5
2023-01-01 New_York 8
2023-01-03 Los_Angeles 25
{"New_York": 10, "Los_Angeles": 25}