| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 512 MB | 190 | 58 | 41 | 44.086% |
The popular PerfectShape online group gathers fans of workouts and healthy lifestyle all over the world. Every group member has managed to gain a certain amount of credits for the trendy M0V3 online sports platform, giving them access to various workout and relaxation resources.
The amount of credits owned may however largely differ from one person to the other. Since PerfectShape members value sharing and solidarity, they decide to redispatch credits by playing the following game:
The N group members are numbered from 1 to N and the game comprises k rounds, for some integer k such that 1 ≤ k ≤ N. During the i-th round of the game, all members except member i give S credits to member i. The game may end after any round, and its outcome will be the minimum amount of credits held by a member of the group after that round.
Your task is to figure out the maximum possible game outcome, across all possible game endings.
The first line of the input contains two integers N and S. Each of the N following lines contains a single integer, the (i + 1)-th line containing the amount of credits Ci initially owned by member i.
The output should contain a single integer value C corresponding to the maximum possible game outcome.
3 10 24 42 38
28
The game proceeds as follows:
The best possible outcome is therefore 28, which corresponds to ending the game after round 1.