首页 > 其他 > 详细

hdu1029(水题)

时间:2017-03-22 21:30:37      阅读:218      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029

好像用不着动态规划。。。

 1 #include<cstdio>
 2 #include<algorithm>
 3 using namespace std;
 4 const int maxn=1000010;
 5 int dp[maxn];
 6 int p[maxn];
 7 
 8 int main()
 9 {
10     int n;
11     while(scanf("%d",&n)!=EOF)
12     {
13         int m=(n+1)/2;
14         int ansm=1,ansi;
15         for(int i=0;i<n;i++)
16         scanf("%d",&p[i]);
17             sort(p,p+n);
18         for(int i=1;i<n;i++)
19         {
20             if(p[i]==p[i-1]) {ansm++; if(ansm>=m) {ansi=p[i];break;}}
21             else ansm=1;
22         }
23         printf("%d\n",ansi);
24     }
25 }

 

hdu1029(水题)

原文:http://www.cnblogs.com/yijiull/p/6601816.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!