| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 14873 | The Unfair Leader Board Giveaway |
|
Description
RITO is a gaming company that is holding an online gaming contest to promote its new game: Last Unit Left (LUL).
The contest takes an open, streaming format: during the contest period, contestants can submit their game score, which will then be placed on a leader board, ranking from highest to lowest.
To enhance engagement, prizes are given out every now and then during the contest period to one of top three contestant on the leader board, chosen randomly.
Upon receiving the prize, the contestant's score is removed from the leader board.
You are to write a C/C++ program to maintain the leader board and provide the prize winner based on external prize drawing results.
Your program should support the following commands:
1. s N S
Record the score S (in the range of 0-1000000 inclusive) for the contestant of name N (three capital English characters) on the leader board. Note on the leader board there can be multiple scores for the same N. You can assume that at any point, all scores on the leader board will be unique (e.g. the case where there are two scores of 100 on the leader board at the same time will not occur.)
2. w1
Output the name of the current first place on leader board. Remove the first place entry after outputting.
3. w2
Output the name of the current second place on leader board. Remove the second place entry after outputting.
4. w3
Output the name of the current third place on leader board. Remove the third place entry after outputting.
Your program MAY use C++ standard library headers.
Hint: You might need to add this two lines of code for fast C++ io in main function before reading any input:
std::ios::sync_with_stdio(false);
std::cin.tie(0);
Input
A new line containing the number of commands to be read in (M, 0 < M <= 106).
Then M lines of command, one command per line.
Output
The names outputted by the w commands, one outcome per line. Each outcome should be newline ('\n') terminated.
If there are not enough entries on the leader board, the w command should give -1 and not modify the leader board.