AdobeOA #2
Count Players Eligible to Level Up
Estimated EasyJudge-ready
Topics (AI-labelled)In-place Arrays
Players with equal scores share the same rank, and a player's rank is 1 plus the number of players with a strictly higher score. Only players whose rank is ≤k and whose score is not 0 are promoted.
Input
The first line contains n k, and the second line contains n scores. The original bounds are 1≤n≤100000, 0≤score≤100, and k≤n with no lower bound; this site adds −10^9≤k≤n, and no one is promoted when k≤0.
Output
Output a single integer answer.
Example 1
Input:
4 3
100 50 50 25
Output:
3
Example 2
Input:
2 2
0 0
Output:
0
Example 3
Input:
3 1
100 100 10
Output:
2
Example notes
The original example promotes 3 players. The other two examples give 0 and 2 respectively. The sample code in the original summary chapter does not exclude scores of 0 and must not be reused.
Editorial
Loading solution…