这道题用二份答案也能做
AC代码如下
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,l=1,r=1e9;
bool check(int x){
long long c1=c,i=0;
long long a1=a;
long long b1=b;
while(c1>=0){
if(i==x) return true;
a1-=(i+1);
b1-=(i+1);
if(a1<0){
c1-=(0-a1);
a1=0;
}
if(b1<0){
c1-=(0-b1);
b1=0;
}
i++;
}
return false;
}
int main(){
scanf("%lld%lld%lld",&a,&b,&c);
while(l<=r){
int mid=(l+r)/2;
if(check(mid)){
l=mid+1;
}else{
r=mid-1;
}
}
printf("%lld",l-1);
return 0;
}