1505.Latest Winning Round

Time Limit: 1s Memory Limit: 256MB

displaylzy has recently been working on a tournament called the "X Points to the Top" system.

Specifically:

There are n players, and at the end of each round, each player will receive a corresponding number of points. The player who ranks $i$-th place in the round will receive $n-i+1$ points.

The rule is that when a player has a total score greater than or equal to $X$ ($score \ge X$) at the end of a round, then that player gets a chance to reach the top.

When a player who has been given a chance to reach the top ranks first in a round, the game ends and that player wins.

Now, given a game situation of $n$ players and a summit score $X$,

Can you determine what is the maximum number of rounds the game will continue after a specific scenario before a player reaches the top?

Input Format(From the terminal/stdin)

The first line contains two integers $n$ and $X$, $(n, X \le 2000)$, denotes the number of players and the summit point.

The second line contains $n$ integers, denotes the current points of each players.

It is guaranteed that the sum of the current points over all players will not exceed $10^5$.

Output Format(To the terminal/stdout)

Output the maximum number of game rounds to go through after the given scenario.

Sample Input 1

Copy
3 8
2 3 1
 · \n
 · · \n

Sample Output 1

Copy
6
 \n

Sample Input 2

Copy
5 20
9 5 5 5 6
 ·  \n
 · · · · \n

Sample Output 2

Copy
9
 \n

Hints

A given game situation must be legal, i.e., derived from a number of rounds of the game.

Source: The 2024 Hunan University Programming Contest

Submit

请先 登录

© 2025 FAQs