JuniorMath
Find the Maximum Achievable Number
Given two integers, num and t. A number x is achievable if it can become equal to num after applying the following operation at most t times:
- Increase or decrease
xby1, and simultaneously increase or decreasenumby1.
Return the maximum possible value of x.
Example 1
Input
num = 4, t = 1Output
6Apply the operation once by decreasing the maximum achievable number by 1 and increasing num by 1, so 6 can become equal to 4.
Example 2
Input
num = 3, t = 2Output
7Apply the operation twice by decreasing the maximum achievable number by 1 and increasing num by 1 each time, so 7 can become equal to 3.
Constraints
- 1 <= num, t <= 50