Skip to content

Commit 83b4cc1

Browse files
committed
Add HDOJ-5364
1 parent 43a6045 commit 83b4cc1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Code/ACM/HDOJ/5364.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# [HDOJ-5364 Distribution money](http://acm.hdu.edu.cn/showproblem.php?pid=5364)
2+
3+
## 解题报告
4+
5+
水题,哈希。
6+
7+
## 代码
8+
9+
```cpp
10+
// 哈希
11+
#include <stdio.h>
12+
#include <stdlib.h>
13+
#include <string.h>
14+
#include <ctype.h>
15+
#include <math.h>
16+
#include <limits.h>
17+
#include <algorithm>
18+
19+
using namespace std;
20+
21+
const int N = 10000;
22+
23+
int money[N];
24+
int n, id;
25+
26+
int main()
27+
{
28+
while (~scanf("%d", &n)) {
29+
memset(money, 0, sizeof(money));
30+
for (int i=0; i<n; ++i) {
31+
scanf("%d", &id);
32+
money[id]++;
33+
}
34+
bool find = false;
35+
for (int i=0; i<N; ++i) {
36+
if (money[i] > n - money[i]) {
37+
printf("%d\n", i);
38+
find = true;
39+
break;
40+
}
41+
}
42+
if (!find) {
43+
puts("-1");
44+
}
45+
}
46+
return 0;
47+
}
48+
```

0 commit comments

Comments
 (0)