Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int maximum(int a, int b, int c) {
  7.   return max(a, max(b, c));
  8. }
  9.  
  10. int maximum(int a, int b) {
  11.   return a > b? a : b;
  12. }
  13.  
  14. int main() {
  15.   ifstream cin("../problem.in");
  16.   ofstream cout("../problem.out");
  17.  
  18.   int testCase;
  19.   cin >> testCase;
  20.   system("pwd");
  21.   while (testCase-- > 0) {
  22.     int a, b, c, n;
  23.     cin >> a >> b >> c >> n;
  24.  
  25.     int total = a + b + c + n;
  26.     int average = total / 3;
  27.     cout << (total % 3 != 0 || maximum(a, b, c) > average ? "NO" : "YES") << endl;
  28.   }
  29.  
  30.   return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement