HDU 1029 Ignatius and the Princess IV 这题有点蛋疼
2015-05-01 19:22
375 查看
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68966#problem/B
题目没有给出每个数的大小,搞的不敢开常数数组。看到别人开个5000的计数数组就过了。。。
看着N达到了999999,心想map肯定会TLE吧,MD,看到别人map也顺利AC,看来我对1s的数量级还是不太能理解啊。。。。
代码:
题目没有给出每个数的大小,搞的不敢开常数数组。看到别人开个5000的计数数组就过了。。。
看着N达到了999999,心想map肯定会TLE吧,MD,看到别人map也顺利AC,看来我对1s的数量级还是不太能理解啊。。。。
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; //map<int,int> mp; int N; int cnt[50000]; int main(){ while(cin>>N){ // mp.clear(); memset(cnt,0,sizeof(cnt)); int t,ans; for(int i=0;i<N;i++){ scanf("%d",&t); cnt[t]++;//mp[t]++; if(cnt[t]==(N+1)/2) ans=t; //if(map[t]==(N+1)/2) ans=t; } printf("%d\n",ans); } return 0; }
相关文章推荐
- HDU 1029 Ignatius and the Princess IV
- HDU - 1029 B - Ignatius and the Princess IV
- 【瞎搞】 HDU 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV 动态规划
- HDU 1029 - Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV(水题)
- hdu_1029_Ignatius and the Princess IV(模拟)
- HDU-1029-Ignatius and the Princess IV(C++ && 小技巧)
- HDU 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV
- Hdu 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV (DP,水题)
- hdu 1029 Ignatius and the Princess IV【stl】
- HDU 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV(快排)
- hdu 1029 Ignatius and the Princess IV(水题)
- hdu 1029 Ignatius and the Princess IV
- HDU 1029 Ignatius and the Princess IV 水题排序
- HDU 1029 Ignatius and the Princess IV
- hdu 1029 Ignatius and the Princess IV