#C7275. Tournament Ranking
Tournament Ranking
Tournament Ranking
You are given a list of participants in a tournament along with their scores. For each dataset, you need to determine the rank of a specified participant. The ranking is based on the participant's score in descending order. If two or more participants have the same score, they share the same rank. The ranking follows the formula:
( rank = 1 + ) (number of participants with a strictly higher score).
Note that the number of problems solved (( P )) is provided for each dataset but is not used for ranking. Your task is to read multiple datasets from standard input and, for each dataset, output the rank of the participant whose ID is given.
inputFormat
Input is given via standard input (stdin). The input consists of multiple datasets. Each dataset starts with a line containing two integers ( M ) and ( P ), where ( M ) is the number of participants and ( P ) is the number of problems solved (which is not used in the ranking). This is followed by ( M ) lines, each containing two integers representing the participant's ID and score. The next line contains the ID of the participant whose rank you need to determine. A line with a single 0 indicates the end of input.
outputFormat
For each dataset, output the rank of the specified participant on a separate line to standard output (stdout).## sample
3 5
1 90
2 95
3 90
1
0
2
</p>