Ankit_132

A

Oct 25th, 2023
206
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. using namespace std;
  3.  
  4. #define ll long long
  5.  
  6. int main() {
  7.     int t;
  8.     cin>>t;
  9.    
  10.     while(t--)
  11.     {
  12.        
  13.         int n;
  14.         cin>>n;
  15.  
  16.         vector<int> a(n);
  17.         for(auto &e: a)
  18.             cin>>e;
  19.  
  20.         ll int tot = accumulate(a.begin(), a.end(), 0);
  21.  
  22.         if(tot%n != 0)
  23.         {
  24.             cout<<"No\n";
  25.             continue;
  26.         }
  27.  
  28.         int avg = tot/n;
  29.  
  30.         int f = 1;
  31.  
  32.         for(auto e: a)
  33.             f &= (abs(e - avg)%2 == 0);
  34.  
  35.         if(f)       cout<<"Yes\n";
  36.         else        cout<<"No\n";
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment