#C4003. Leaderboard Ranking Manager

    ID: 47494 Type: Default 1000ms 256MiB

Leaderboard Ranking Manager

Leaderboard Ranking Manager

In this problem, you are tasked with managing a leaderboard for a competitive game. Each player is identified by a unique ID and has an associated level and score. The ranking rules are as follows:

  • Players are ordered primarily by their level in descending order.
  • If two players have the same level, the player with the higher score is ranked higher.
  • If both the level and score are equal, the players will share the same rank.

The rank is calculated such that if a player at index \(i\) (0-indexed in the sorted order) is not tied with the previous player, his rank is \(i+1\). In the case of a tie, they share the same rank as the previous player.

inputFormat

The input is given via standard input (stdin) and consists of multiple lines. The first part of the input contains player data in the format "id,level,score" (each being an integer). The player data ends when the line "0,0,0" is encountered. The subsequent lines provide query player IDs (one per line), and each of these must be processed.

outputFormat

For each queried player ID, output the rank on a separate line. If a player ID does not exist in the leaderboard, output "Player not found".

## sample
1,10,500
2,10,600
3,20,400
4,5,700
5,10,500
0,0,0
1
2
3
4
5
3

2 1 5 3

</p>