当前位置: 代码迷 >> 综合 >> 计蒜客 ACM Nanning 2017 J. Rearrangement
  详细解决方案

计蒜客 ACM Nanning 2017 J. Rearrangement

热度:3   发布时间:2023-12-01 21:22:35.0

题目传送门
代码:

#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"); }
}