码迷,mamicode.com
首页 > 其他好文 > 详细

腾讯数据岗

时间:2019-09-01 21:57:15      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:str   out   i++   using   col   include   max   std   time   

第一题:

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

 

腾讯数据岗

标签:str   out   i++   using   col   include   max   std   time   

原文地址:https://www.cnblogs.com/joelwang/p/11443548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!