#C12966. Highest Scores
Highest Scores
Highest Scores
You are given a list of records, each record consisting of a student name and an integer score. Your task is to determine the highest score for each student and output the result as a dictionary in JSON format.
The first line of input contains an integer \( n \), representing the number of records. Each of the next \( n \) lines contains a student's name and score separated by a space. You need to compute the maximum score for each student and print the resulting dictionary to stdout.
Note: The output should be a valid JSON dictionary where keys are student names (wrapped in double quotes) and values are their highest scores.
inputFormat
The input is read from standard input (stdin) and has the following format:
n name1 score1 name2 score2 ... namen scoren
where:
n
is an integer representing the number of records.- Each of the next
n
lines contains a student name (a string) and a score (an integer) separated by a space.
outputFormat
Output to standard output (stdout) a JSON formatted dictionary containing student names as keys and their highest score as values.
Example: {"John": 92, "Jane": 90}
1
John 85
{"John": 85}