题目链接: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 ", i); 42 } 43 } 44 return 0; 45 }