#C10773. Weather Data Summary

    ID: 40015 Type: Default 1000ms 256MiB

Weather Data Summary

Weather Data Summary

You are given weather data for a series of days. Each record contains three fields: a date in the format YYYY-MM-DD, an integer temperature, and a weather type string. Your task is to compute the average temperature \(A = \frac{\sum_{i=1}^{n} \text{temperature}_i}{n}\), count the number of occurrences for each weather type, and determine the day with the highest temperature (hottest) as well as the day with the lowest temperature (coldest).

The input is provided from standard input and the result must be printed to standard output as a JSON object.

inputFormat

The first line of input contains an integer \(n\) representing the number of records. The following \(n\) lines each contain a record with three space-separated values: a date (YYYY-MM-DD), a temperature (an integer), and a weather type (a string).

outputFormat

Output a single line JSON object with the keys:

  • average_temperature: a float representing the average temperature (rounded to one decimal place).
  • weather_count: an object mapping each weather type to its count.
  • hottest_day: a string representing the date with the highest temperature.
  • coldest_day: a string representing the date with the lowest temperature.
## sample
5
2023-01-01 20 sunny
2023-01-02 10 cloudy
2023-01-03 15 rainy
2023-01-04 25 sunny
2023-01-05 -5 snowy
{"average_temperature":13.0,"weather_count":{"cloudy":1,"rainy":1,"snowy":1,"sunny":2},"hottest_day":"2023-01-04","coldest_day":"2023-01-05"}