2025-01-09 20:29:41 +08:00
< p > Given two integers, < code > num< / code > and < code > t< / code > . A < strong > number < / strong > < code > x< / code > < strong > < / strong > is< strong > achievable< / strong > if it can become equal to < code > num< / code > after applying the following operation < strong > at most< / strong > < code > t< / code > times:< / p >
2023-07-16 12:28:13 +08:00
< ul >
2025-01-09 20:29:41 +08:00
< li > Increase or decrease < code > x< / code > by < code > 1< / code > , and < em > simultaneously< / em > increase or decrease < code > num< / code > by < code > 1< / code > .< / li >
2023-07-16 12:28:13 +08:00
< / ul >
2025-01-09 20:29:41 +08:00
< p > Return the < strong > maximum < / strong > possible value of < code > x< / code > .< / p >
2023-07-16 12:28:13 +08:00
< p > < / p >
< p > < strong class = "example" > Example 1:< / strong > < / p >
2025-01-09 20:29:41 +08:00
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > num = 4, t = 1< / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > 6< / span > < / p >
< p > < strong > Explanation:< / strong > < / p >
2023-07-16 12:28:13 +08:00
2025-01-09 20:29:41 +08:00
< p > Apply the following operation once to make the maximum achievable number equal to < code > num< / code > :< / p >
< ul >
< li > Decrease the maximum achievable number by 1, and increase < code > num< / code > by 1.< / li >
< / ul >
< / div >
2023-07-16 12:28:13 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2025-01-09 20:29:41 +08:00
< div class = "example-block" >
< p > < strong > Input:< / strong > < span class = "example-io" > num = 3, t = 2< / span > < / p >
< p > < strong > Output:< / strong > < span class = "example-io" > 7< / span > < / p >
< p > < strong > Explanation:< / strong > < / p >
< p > Apply the following operation twice to make the maximum achievable number equal to < code > num< / code > :< / p >
< ul >
< li > Decrease the maximum achievable number by 1, and increase < code > num< / code > by 1.< / li >
< / ul >
< / div >
2023-07-16 12:28:13 +08:00
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = num, t < = 50< / code > < / li >
< / ul >