题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=1800

题意

给出N个人的 level 然后 高的level 的 人 是可以携带 比他低level 的人 一起坐一把 魔法扫帚

要求所有人都有扫帚坐 求最少需要几把扫帚

思路

假如我们将数据大到小排序 第一次 将第一个人推入队列 然后后面的每一个人 只需要判断 先前有的队列 是否有队列可以让他入队 如果有 那么就让它入队 如果没有 就需要一个新的队列

但是这个算法 时间复杂度 比较高

其实 我们最后可以发现 我们只需要 求出 重复LEVEL的人 最多的 是多少 就需要多少把扫帚

AC代码

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<list>
#include<stack>
#include <queue> #define CLR(a, b) memset(a, (b), sizeof(a)) using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 3e3 + 5;
const int MOD = 1e10; int main()
{
int n;
while(~scanf("%d", &n))
{
map <int, int> m;
int num;
int ans = 0;
for (int i = 0; i < n; i++)
{
scanf("%d", &num);
m[num]++;
ans = max(ans, m[num]);
}
printf("%d\n", ans);
}
}

HDU - 1800 Flying to the Mars 【贪心】的更多相关文章

  1. --hdu 1800 Flying to the Mars(贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Ac code: #include<stdio.h> #include<std ...

  2. hdu 1800 Flying to the Mars

    Flying to the Mars 题意:找出题给的最少的递增序列(严格递增)的个数,其中序列中每个数字不多于30位:序列长度不长于3000: input: 4 (n) 10 20 30 04 ou ...

  3. HDU 1800——Flying to the Mars——————【字符串哈希】

    Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  4. HDU 1800 Flying to the Mars 字典树,STL中的map ,哈希树

    http://acm.hdu.edu.cn/showproblem.php?pid=1800 字典树 #include<iostream> #include<string.h> ...

  5. HDU 1800 Flying to the Mars Trie或者hash

    http://acm.hdu.edu.cn/showproblem.php?pid=1800 题目大意: 又是废话连篇 给你一些由数字组成的字符串,判断去掉前导0后那个字符串出现频率最高. 一开始敲h ...

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

    题目 又来了string的基本用法 //less than 30 digits //等级长度甚至是超过了int64,所以要用字符串来模拟,然后注意去掉前导零 //最多重复的个数就是答案 //关于str ...

  7. 杭电 1800 Flying to the Mars(贪心)

    http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Oth ...

  8. HDOJ.1800 Flying to the Mars(贪心+map)

    Flying to the Mars 点我挑战题目 题意分析 有n个人,每个人都有一定的等级,高等级的人可以教低等级的人骑扫帚,并且他们可以共用一个扫帚,问至少需要几个扫帚. 这道题与最少拦截系统有异 ...

  9. HDOJ 1800 Flying to the Mars 盲目搜索......................so easy...........

    check the original problem here:http://acm.hdu.edu.cn/showproblem.php?pid=1800 the AC code: #include ...

随机推荐

  1. 使用Cocos studio创建一个简单的project

    前不久我接到了一个项目,项目要求使用Cocos2d-X的最新版本号,Cocos2d-X3.4.对于一直在陶醉在Cocos2d-X2.2.3的世界中的我开说,使用Cocos2d-X3.4忽然认为有点不适 ...

  2. Babel中的stage-0,stage-1,stage-2以及stage-3

    大家知道,将ES6代码编译为ES5时,我们常用到Babel这个编译工具.大家参考一些网上的文章或者官方文档,里面常会建议大家在.babelrc中输入如下代码: { "presets" ...

  3. mysql命令行导入和导出数据

    首先打开命令窗口,输入命令:mysql -h localhost -u selffabu -p 连接成功后,进行下面的操作 MySQL中导出CSV格式数据的SQL语句样本如下: select * fr ...

  4. SpringBoot Idea 启动报错 Process finished with exit code 1

    问题描述:没有其他任何错误日志,只有Process finished with exit code 1 问题原因:Maven POM.xml问题造成 由于是properties是我直接从其他项目中拷贝 ...

  5. spring boot集成activemq

    spring boot集成activemq 转自:https://blog.csdn.net/maiyikai/article/details/77199300

  6. 线段树专题—HDU1698 Just a Hook

    题意:t组数据,给一个n.m表示n长度的钩和m次操作.初始钩子的每单位长度的价值为1,接下来输入 x,y,k 的操作把钩子[x,y]区间的价值替换为k,求m次操作后钩子的价值为多少 分析:成段替换.最 ...

  7. 使用 SourceTree 遇到冲突的解决方法

    首先,更新代码之前先 git stash ,然后 git pull ,再 git stash pop 这时候如果本地改的代码跟线上的冲突了,就报错了.那么就需要手动解决冲突. 打开存在冲突的文件,会看 ...

  8. Android SQLite基本用法

    SQLite简介 Google为Andriod的较大的数据处理提供了SQLite,他在数据存储.管理.维护等各方面都相当出色,功能也非常的强大.SQLite具备下列特点: 1.轻量级 使用 SQLit ...

  9. Linux环境下,使用PHP创建一个守护进程

    <?php $pid = pcntl_fork(); // fork if ($pid < 0) exit; else if ($pid) // parent exit; else { / ...

  10. Unity3d 摇杆奖励

    单个单元: publicclass RockerSingle : MonoBehaviour { // 枚举.类别 RockerType  rockerType; //是否有效,最上面的为无效,即为f ...