#K55922. Find Participant Rank

    ID: 30083 Type: Default 1000ms 256MiB

Find Participant Rank

Find Participant Rank

You are given scores for n participants along with their identifiers. Your task is to determine the rank of a given target participant when the list is sorted in descending order by score. In case of ties (i.e. participants having the same score), the participant appearing earlier in the input retains the higher rank.

The ranking is 1-indexed. That is, the highest participant gets a rank of 1.

Formally, if we denote the participants by a sequence \(\{(id_i, s_i)\}_{i=1}^{n}\) and sort them into a new sequence \(\{(id'_i, s'_i)\}_{i=1}^{n}\) satisfying \[ s'_1 \geq s'_2 \geq \cdots \geq s'_n, \] with the stability property for equal \(s\) values, then if the target identifier is \(t\), you must output the unique index \(r\) such that \(id'_r = t\).

Assume that the target participant is always present in the list.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer \(n\) which is the number of participants.
  • The next \(n\) lines each contain a participant's identifier (a string) and an integer score, separated by a space.
  • The last line contains the target participant's identifier.

outputFormat

Print the rank (a single integer) of the target participant to stdout as determined by the described rules.

## sample
5
alice 1500
bob 2000
charlie 1700
dave 1600
ellen 1800
charlie
3