第一题:
#include <iostream> #include <vector> using namespace std; int main() { int T; cin>>T; for(int id=0;id<T;id++){ int n,max_times=0; cin>>n; vector<int> arr(n+1,0); for(int i=1;i<=n;i++){ int x; cin>>x; arr[x]+=1; if(arr[x]>max_times) max_times=arr[x]; } if(max_times>n/2) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0; }