比赛 noip2016普及练习2 评测结果 AAAAAAAAAA
题目名称 谁是卧底 最终得分 100
用户昵称 Bravo ChaoS 运行时间 0.022 s
代码语言 C++ 内存使用 0.35 MiB
提交时间 2016-11-07 20:05:17
显示代码纯文本
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. #include<iostream>
  5. #include<map>
  6. using namespace std;
  7.  
  8. const int maxn=10010;
  9.  
  10. class input
  11. {
  12. public:
  13. input& operator >> (int& x)
  14. {
  15. char c=' ';x=0;
  16. while(c<'0' || c>'9') c=getchar();
  17. while(c>='0' && c<='9') x=x*10+c-'0',c=getchar();
  18. return *this;
  19. }
  20. }in;
  21.  
  22. map<int,int> mp;
  23. int a[maxn],cur=0,n,m;
  24.  
  25. int main()
  26. {
  27. freopen("leader.in","r",stdin);
  28. freopen("leader.out","w",stdout);
  29. in>>m>>n;
  30. for(int i=0,t;i<n;++i) {in>>t;if(!mp[t]) a[++cur]=t;mp[t]++;}
  31. n>>=1;
  32. for(int i=1;i<=cur;++i) if(mp[a[i]]>n)
  33. {
  34. cout<<a[i]<<endl;
  35. return 0;
  36. }
  37. printf("-1\n");
  38. return 0;
  39. }
  40.