去哪儿笔试题为什么不能AC100%


#include<iostream>
#include<map>
using namespace std;
int main()
{
int num;
map<int,int>hash;
while(cin>>num)
{
if(hash.find(num)!=hash.end())
{
hash[num]++;
}
else
{
hash[num]=1;
}
}
int maxnum=0;int sum=0;int id=-1;
for(map<int,int>::iterator iter=hash.begin();iter!=hash.end();iter++)
{
sum=sum+iter->second;
if(iter->second>maxnum)
{
maxnum=iter->second;
id=iter->first;
}
}
if(2*maxnum>sum)
{
cout<<id<<endl;
}
else
{
cout<<-1<<endl;
}
}
全部评论
这题我感觉不难,为啥就不能全部通过呢
点赞
送花
回复
分享
发布于 2016-09-20 11:43
我都没收到去哪儿的笔试通知?心都碎了
点赞
送花
回复
分享
发布于 2016-09-20 13:09
秋招专场
校招火热招聘中
官网直投
没收到
点赞
送花
回复
分享
发布于 2016-09-20 13:53

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务