首页 > 其他 > 详细

HDU 1029 Ignatius and the Princess IV

时间:2019-08-03 16:14:36      阅读:71      评论:0      收藏:0      [点我收藏+]

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

分析:在dp专题里,但是数据给水了,导致桶排直接过了

 1 #include<iostream>
 2 #include<sstream>
 3 #include<cstdio>
 4 #include<cstdlib>
 5 #include<string>
 6 #include<cstring>
 7 #include<algorithm>
 8 #include<functional>
 9 #include<iomanip>
10 #include<numeric>
11 #include<cmath>
12 #include<queue>
13 #include<vector>
14 #include<set>
15 #include<cctype>
16 #define PI acos(-1.0)
17 const int INF = 0x3f3f3f3f;
18 const int NINF = -INF - 1;
19 const int maxn = 1e6 + 5;
20 typedef long long ll;
21 using namespace std;
22 int n;
23 int sum[maxn];
24 int main()
25 {
26     while (scanf("%d", &n) != EOF)
27     {
28         int num = (n + 1) / 2;
29         memset(sum, 0, sizeof(sum));
30         int len = 0;
31         for (int i = 0; i < n; ++i)
32         {
33             int x;
34             scanf("%d", &x);
35             sum[x]++;
36             len = max(len, x);
37         }
38         for (int i = 0; i <= len; ++i)
39         {
40             if (sum[i] >= num)
41                 printf("%d\n", i);
42         }
43     }
44     return 0;
45 }

 

HDU 1029 Ignatius and the Princess IV

原文:https://www.cnblogs.com/veasky/p/11294940.html

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