Author: | A. Verkholat | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
Petya likes to play MMORPG and wants to beat everyone in PvP.
He just bought a cool weapon and wants to enhance it.
Initially enhancement level of the weapon is zero.
Petya has N enhancement stones of different levels in his inventory.
To raise enhancement level by 1, you need K stones of a higher level than the current level of the weapon, after this operation the stones disappear.
It is also possible to create a stone of one level higher from M stones of the same level.
What is the maximum enhancement level of the weapon Petya can reach?
First line contains 3 integers: N, K and M.
N - number of enhancement stones.
K - number of stones to raise enhancement level of the weapon by 1.
M - number of stones to craft a stone of a level higher by 1.
Second line contains an array A from N integers - levels of enhancement stones.
One integer - maximum enhancement level of the weapon that Petya can reach.
1 ≤ N ≤ 105
1 ≤ K ≤ 109
1 ≤ M ≤ 109
1 ≤ Ai ≤ 109
1-st: Petya crafts 3 stones of level 3 and uses it in any order.
2-nd: uses stones in order 2, 3, 4, 5.
3-rd: uses 2 stones of level 1, crafts stone of level 2 and uses 2 stones of level 2.
4-th: uses 1 stone of level 1.
5-th: uses two stones one time.
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|