#C1950. Determine Participant Rank

    ID: 45212 Type: Default 1000ms 256MiB

Determine Participant Rank

Determine Participant Rank

You are given P participants with their respective scores. A specific participant is identified by an index X (1-indexed). The rank of the participant is determined by comparing the unique scores of all participants in descending order. In other words, if you create a sorted list of unique scores from highest to lowest, the rank of the participant is the 1-indexed position of their score within this list.

For example, if P = 5, X = 3, and the scores are [100, 200, 100, 150, 200], the unique scores in descending order would be [200, 150, 100]. Thus, the participant’s score of 100 would have a rank of 3.

inputFormat

The input is provided via standard input (stdin) and consists of three lines:

  1. The first line contains an integer P, the number of participants.
  2. The second line contains an integer X, representing the specific participant's index (1-indexed).
  3. The third line contains P space-separated integers, representing the participants' scores.

outputFormat

The output is a single integer printed to standard output (stdout), which represents the rank of the participant X based on the descending order of unique scores.## sample

5
3
100 200 100 150 200
3