Practice

Tournament Event Medals

2025/May/June·Variant 1·Q11·[15 marks]
HARD2D Arrays

Three named competitors each take part in three events. Read the three names, then a score from 0 to 100 for every competitor in every event (re-read a score until it is in range).

Award a medal to every competitor who has the highest score in an event (ties share the medal). Also award a medal to every competitor with the highest total across all three events.

Input: Three names, then nine scores in competitor-major order (all of competitor 1's events, then competitor 2, then competitor 3). Output: For each event a header Event <n> medal followed by the medal winner names, then Highest total followed by those names.

Example:

Input:  Ali
        Bob
        Cai
        80
        70
        90
        80
        85
        60
        90
        85
        90
Output: Event 1 medal
        Cai
        Event 2 medal
        Bob
        Cai
        Event 3 medal
        Ali
        Cai
        Highest total
        Cai

Sample Test Cases

Test 1: Mixed medals with two event ties
Inputs: Ali, Bob, Cai, 80, 70, 90, 80, 85, 60, 90, 85, 90
Expected: Event 1 medal Cai Event 2 medal Bob Cai Event 3 medal Ali Cai Highest total Cai
Test 2: Negative score rejected, then Ann sweeps
Inputs: Ann, Ben, Cat, -1, 100, 100, 100, 0, 0, 0, 50, 50, 50
Expected: Event 1 medal Ann Event 2 medal Ann Event 3 medal Ann Highest total Ann