#K2736. Leaderboard Ranking for New Players
Leaderboard Ranking for New Players
Leaderboard Ranking for New Players
You are given an existing leaderboard of scores in descending order (which may contain duplicates) and a list of new player scores. Your task is to determine the rank of each new player. The rank is defined as follows:
For a new score s, its rank is the smallest index i (1-indexed) such that \[ s \geq score_i \] in the leaderboard with score_i representing the unique scores in descending order. If s is less than all the scores, then its rank is one more than the number of unique scores.
Note: If the leaderboard is empty, every new player gets a rank of 1.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer
n
representing the number of scores in the current leaderboard. - If
n > 0
, the next line containsn
space-separated integers representing the scores in descending order. Duplicates may be present. - An integer
m
representing the number of new player scores. - A line with
m
space-separated integers representing the new player scores.
outputFormat
Output to standard output (stdout) a single line with m
integers separated by spaces. The i-th
integer represents the rank of the i-th
new player.
6
100 90 90 80 75 60
5
50 65 77 90 102
6 5 4 2 1