fork download
  1. // بسم الله الرحمن الرحيم
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define FlashIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(NULL);
  5. #define all(v) v.begin(), v.end()
  6. #define rall(v) v.rbegin(), v.rend()
  7. #define int long long
  8. #define el "\n"
  9. #define sp " "
  10.  
  11. int dx[4] = {1, -1, 0, 0};
  12. int dy[4] = {0, 0, 1, -1};
  13.  
  14. const int oo = 2e18, Mod = 1e9+7;
  15. const int N = 1e5;
  16.  
  17.  
  18.  
  19.  
  20. void Art() {
  21. int a,b,c,n;
  22. cin>>a>>b>>c>>n;
  23. int mx=max({a,b,c});
  24. int cnt=3*mx-(a+b+c);
  25. if(n<cnt){
  26. cout<<"NO"<<el;
  27. return;
  28. }
  29. n-=cnt;
  30. if(n%3==0)
  31. cout<<"YES"<<el;
  32. else cout<<"NO"<<el;
  33. }
  34.  
  35.  
  36.  
  37.  
  38. signed main() {
  39. FlashIO;
  40. int tc = 1;
  41. cin >> tc;
  42. while(tc--){
  43. Art();
  44. }
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
NO