题目传送门
代码:
#include<bits/stdc++.h>
using namespace std;int du[3];int main(){int T;scanf("%d",&T);while(T--){du[0]=du[1]=du[2]=0;int n;scanf("%d",&n);for(int i=1,val;i<=2*n;i++){scanf("%d",&val);du[val%3]++;}if(du[0]>n) printf("NO\n");else if(du[1]==0) printf("YES\n");else if(du[2]==0) printf("YES\n");else if(du[1]%2 && du[0]>=2) printf("YES\n");else if(du[2]%2 && du[0]>=2) printf("YES\n");else if(du[1]%2==0 && du[0]>=3) printf("YES\n");else if(du[2]%2==0 && du[0]>=3) printf("YES\n");else printf("NO\n"); }
}