https://codeforces.com/gym/580226/problem/B
#include<bits/stdc++.h>
#define lc p<<1
#define rc p<<1|1
#define INF 2e9
using namespace std;
#define endl '\n'
using ll = long long;
using pii = pair<ll, ll>;
const double PI = acos(-1);
const int N=1e4+10;
void solve(){
ll a,b,c,m;
cin>>a>>b>>c>>m;
ll cnta=a-1,cntb=b-1,cntc=c-1;
ll cnt=cnta+cntb+cntc;
ll lmi=max(max(cnta-(b+c),(ll)0),max(max((ll)0,cntb-(a+c)),max((ll)0,cntc-(a+b))));
if(m<=cnt&&m>=lmi) {
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
cin>>T;
while (T--) {
solve();
}
return 0;
}
标签:cntc,cntb,cnta,max,ll,相邻,字符串,const
From: https://www.cnblogs.com/laileou/p/18666618