IBMOA #46
Max Index
估计中等可在线判题
You start at index 0. At step j you may move forward j cells or stay in place, for steps steps in total, and you must never stop at badIndex at any moment. Find the maximum final index. If the starting point itself is forbidden, there is no valid path, and this site outputs -1.
输入格式
One line containing steps badIndex. Original bound: 1≤steps≤2000; the original bound on badIndex is missing, and on this site 0≤badIndex≤10^9.
输出格式
Output one integer, the answer.
样例 1
输入:
4 6
输出:
9
样例 2
输入:
3 4
输出:
6
样例 3
输入:
2 0
输出:
-1
样例说明
The examples give 9, 6 and -1 respectively.