#K54137. Calculate Average Movie Ratings

    ID: 29687 Type: Default 1000ms 256MiB

Calculate Average Movie Ratings

Calculate Average Movie Ratings

You are given a JSON object representing a collection of movies. Each key in the object is a movie title, and its corresponding value is an array of integer ratings. Your task is to calculate the average rating for each movie. The average rating should be the arithmetic mean of the ratings rounded to the nearest whole number. If a movie has no ratings, its average rating should be 0.

Note: The formula for the average rating for a movie with ratings \(r_1, r_2, \ldots, r_n\) is:

[ \text{average} = \text{round}\Big(\frac{r_1 + r_2 + \cdots + r_n}{n}\Big) \quad \text{if } n > 0, \quad \text{else } 0. ]

The input will be given as a JSON string via standard input and you are required to output the result as a JSON string to standard output.

inputFormat

The input is a single JSON string provided via standard input. The JSON object has movie titles as keys and an array of integer ratings as values. Example:

{"Inception": [10, 9, 8, 9, 10]}

outputFormat

The output should be a single JSON string printed to standard output. This JSON object will have the same keys (movie titles) with their corresponding average ratings (rounded to the nearest whole number) as values.

## sample
{"Inception": [10, 9, 8, 9, 10]}
{"Inception":9}