#C236. Best Positions Across Events
Best Positions Across Events
Best Positions Across Events
You are given the results of several sporting events. Each event has a list of participants along with the position they achieved (where a lower number indicates a better result). Your task is to determine the best position each student achieved across all events.
The input is provided via standard input (stdin
) and the output should be printed to standard output (stdout
). The output must list each student's name with their best (i.e., smallest) position, and the list should be sorted in alphabetical order by the student's name.
Use the latex format for any formula if needed, for example, the relation to choose the best position is given by: \( \min\{position_1, position_2, \dots, position_n\} \).
inputFormat
The input starts with an integer E, representing the number of events. For each event, there is a line containing the event name (a string without spaces) and an integer N, the number of participants in that event. Then follow N lines, each containing a student's name (a string without spaces) and an integer indicating the position they achieved. If E is 0, there are no further inputs.
outputFormat
For each unique student, output a line containing the student’s name and their best (smallest) position separated by a space. The students should be listed in alphabetical order.## sample
1
100m 3
Alice 1
Bob 2
Celine 3
Alice 1
Bob 2
Celine 3
</p>