AmazonOA #184
Find Optimal Level
估计中等可在线判题
In one operation, choose two different positions: add incVal to one inventory and subtract decVal from the other; incVal≤decVal. The operation may be performed any number of times, and in the end every inventory must be strictly positive (negative values are allowed along the way). Maximize the final minimum inventory.
输入格式
The first line contains n incVal decVal; the second line contains the inventories. 2≤n≤200000; inventories 1..10^9; 1≤incVal≤decVal≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
2 2 3
1 9
输出:
3
样例 2
输入:
2 1 1
5 5
输出:
5
样例 3
输入:
3 1 2
1 2 3
输出:
1
样例说明
The answers are 3, 5 and 1.