#2769

Find the Maximum Achievable Number

easy · 91.2% accepted · 520 likes · top 100%

math

Description

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 x by 1, and simultaneously increase or decrease num by 1.

Return the maximum possible value of x.

Solution