#K56412. Highest Scores Across Games
Highest Scores Across Games
Highest Scores Across Games
Problem Statement:
You are given a series of games. Each game has several participants and their corresponding scores. A participant may appear in multiple games with different scores. Your task is to determine the highest score each participant achieved across all games.
Input Format:
The first line contains an integer (m) representing the number of games. For each game, the first line contains an integer (n) denoting the number of participants. The following (n) lines each contain a participant's ID (a string) and their score (an integer), separated by a space.
Output Format:
For each participant, print a line with the participant's ID and their highest score separated by a space. The results must be sorted in lexicographical order by the participant's ID.
Example:
Input:
2
3
Alice 300
Bob 250
Charlie 400
2
Alice 350
Charlie 450
Output:
Alice 350
Bob 250
Charlie 450
inputFormat
The input is provided via standard input (stdin) and structured as follows:
- The first line contains an integer (m), the number of games.
- For each game:
- The first line contains an integer (n), the number of participants in that game.
- Each of the next (n) lines contains a participant's ID and their score, separated by a space.
Note: Participant IDs are strings and scores are integers.
outputFormat
Print the highest score for each participant. For every participant, output a line containing the participant's ID and their highest score separated by a space. The results must be sorted by participant ID in lexicographical order.## sample
2
3
Alice 300
Bob 250
Charlie 400
2
Alice 350
Charlie 450
Alice 350
Bob 250
Charlie 450
</p>