Text Share Online

2.Question

A group of friends is playing a video game where players earn points. At the end of a round, players who achieve at least rank k can “level up” their characters. Given the scores of players at the end of the round, determine how many players will level up.

 

Notes:

  • Players with equal scores share the same rank, and the next player with a lower score takes the subsequent rank position. For instance, if four players finish with scores ranking them as 1, 1, 1, and 4, the first three players tie for first place, and the next player is ranked fourth.
  • No player with a score of 0 can level up, regardless of rank.

 

Example

n = 4

k = 3

scores = [100, 50, 50, 25]

 

These players’ ranks are [1, 2, 2, 4]. Because the players need to have a rank of at least k = 3 to level up, only the first three players qualify. Therefore, the answer is 3.

Share This: