[HDOJ1800]Flying to the Mars

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

看图明白的题意……贪心的思路。先排序,让一个等级高的尽可能多地带小弟,然后记下有多少组即可。

 1 #include <algorithm>
 2 #include <iostream>
 3 #include <iomanip>
 4 #include <cstring>
 5 #include <climits>
 6 #include <complex>
 7 #include <fstream>
 8 #include <cassert>
 9 #include <cstdio>
10 #include <bitset>
11 #include <vector>
12 #include <deque>
13 #include <queue>
14 #include <stack>
15 #include <ctime>
16 #include <set>
17 #include <map>
18 #include <cmath>
19
20 using namespace std;
21
22 const int maxn = 3010;
23 int n, x, c;
24 int s[maxn];
25
26 int main() {
27     // freopen("in", "r", stdin);
28     while(~scanf("%d", &n)) {
29         c = 1;
30         x = 1;
31         for(int i = 0; i < n; i++) {
32             scanf("%d", &s[i]);
33         }
34         sort(s, s+n);
35         for(int i = 1; i < n; i++) {
36             s[i]==s[i-1]?x=max(x,++c):c=1;
37         }
38         printf("%d\n", x);
39     }
40 }

转而一想,就是算这一堆数据里出现次数最多的那个数据。因为有前置0的问题,可以作为字符串处理,用hash或者trie来做。

时间: 2024-10-25 20:42:44

[HDOJ1800]Flying to the Mars的相关文章

hdu1800 Flying to the Mars(字典树)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 14340    Accepted Submission(s): 4572 Problem Description In the year 8888

hdu---(1800)Flying to the Mars(trie树)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11228    Accepted Submission(s): 3619 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul

HDU 1800 Flying to the Mars (水题)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11099    Accepted Submission(s): 3572 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul

HDU 1800 Flying to the Mars(字典树)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12767    Accepted Submission(s): 4048 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popu

HDU 1800:Flying to the Mars

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10817    Accepted Submission(s): 3469 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popu

杭电 HDU ACM 1800 Flying to the Mars

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12471    Accepted Submission(s): 3963 Problem Description In the year 8888,  the Earth is ruled by the PPF Empire . As the pop

杭电 1800 Flying to the Mars(贪心)

http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10798    Accepted Submission(s): 3461 Problem Description In the year 8888, the

hdu 1800 Flying to the Mars(水 ,贪心)

其实就是求最大的相同的数的多少.. 我是把它当字符串输入..解决前导0的问题.. #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; int main() { char s[35]; int w[3500]; __int64 qq[3500]; int a; while(~scanf("%d",&a

hdu 1800 Flying to the Mars(简单模拟,string,字符串)

题目 又来了string的基本用法 //less than 30 digits //等级长度甚至是超过了int64,所以要用字符串来模拟,然后注意去掉前导零 //最多重复的个数就是答案 //关于string的修改增加的用法 #include <cstdio> #include<iostream> #include <cstring> #include <algorithm> #include<string> using namespace std