fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int t;
  7. cin>>t;
  8. while(t--){
  9. int a,b,c,n;
  10. cin>>a>>b>>c>>n;
  11. int themax=max({a,b,c});
  12. n=n-(themax-a);
  13. n=n-(themax-b);
  14. n=n-(themax-c);
  15. if(n%3==0){
  16. cout<<"YES"<<endl;
  17. }
  18. else{
  19. cout<<"NO"<<endl;
  20. }
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5280KB
stdin
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
stdout
YES
YES
NO
NO
YES