NutanixOA #6
Number of Players (for MTS2)
Estimated EasyJudge-ready
Topics (AI-labelled)In-place ArraysHashing
Count the players who can level up under competition ranking: players with the same score share the same rank, and the rank of the next distinct score equals its position in the sorted order; players with a score of 0 never level up.
The standard input/output format and any supplementary ranges on this site are as defined in this problem statement.
Input
The first line contains n k (1≤n≤100000, 1≤k≤n), and the next line contains n scores (0≤score≤100).
Output
Output the number of players whose rank does not exceed k and whose score is greater than 0.
Example 1
Input:
4 3
100 50 50 25
Output:
3
Example 2
Input:
5 4
20 40 60 80 100
Output:
4
Example 3
Input:
5 4
2 2 3 4 5
Output:
5
Editorial
Loading solution…