hdu_1800

简单排一下序,从大开始把比他小的都访问一遍,ans++;

#include <iostream>
#include <stdio.h>
#include <algorithm> using namespace std; struct dat
{
int level;
int visit;
}data[]; bool cmp(dat a, dat b)
{
return a.level > b.level; } int main()
{
int n; while(scanf("%d", &n)!=-)
{
for(int i=; i<n; i++)
{
scanf("%d", &data[i].level);
data[i].visit=;
} sort(data, data+n, cmp); int ans=;
for(int i=; i<n; i++)
{
if(!data[i].visit)
{
data[i].visit=;
int temp=i;
ans++;
for(int j=; j<n; j++)
{
if(!data[j].visit && data[temp].level>data[j].level)
{
data[j].visit=;
temp=j; }
}
}
}
printf("%d\n", ans);
} return ;
}

hdu_2124

排个序,用 l 从大开始减去block的大小,记录用的block块数, 最后 l > 0 , 则输出impossible,否则输出块数。

#include <iostream>
#include <stdio.h>
#include <algorithm> using namespace std; bool cmp(int a, int b)
{
return a>b;
} int main()
{
int l, n, block[];
while(scanf("%d%d", &l, &n)!=-)
{
for(int i=; i<n; i++)
{
scanf("%d", &block[i]);
}
sort(block, block+n, cmp); int ans=;
for(int i=; i<n && l!=; i++)
{
if(l>=block[i])
{
l-=block[i];
ans++;
}
else
{
l=;
ans++;
break;
}
}
if(l!=)
printf("impossible\n");
else
printf("%d\n", ans);
}
return ;
}

hdu_2124 Flying to the Mars & hdu_1800 Repair the Wall 贪心水题的更多相关文章

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

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

  2. hdu 1800 Flying to the Mars

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

  3. (贪心 map) Flying to the Mars hdu1800

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

  4. 杭电 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 ...

  5. Flying to the Mars

    D - Flying to the Mars Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I ...

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

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

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

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

  8. HDU1800 Flying to the Mars 【贪心】

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

  9. HDU2124 Repair the Wall(贪心)

    Problem Description Long time ago , Kitty lived in a small village. The air was fresh and the scener ...

随机推荐

  1. WPF使用 Gmap.NET 绘制极坐标运动轨迹

    大家好,已经很久没有更新了,今天写一篇关于WPF 使用 Gmap.NET 相关的,网上很多Winform的很**,所以我给Wpf进行一些补充.虽然它已经很久没有更新了,但是也只能用这个了.没别的好选择 ...

  2. 【Java技术系列】爱情36技之记忆永存

    1.  关注“一猿小讲”的伙伴们都清楚,Java 那小子带着心爱的 Python 菇凉,去了一趟浪漫的土耳其,然后一起又去了东京和巴黎,接着 Python 菇凉自己又去了云南的大理. 就在昨天,Pyt ...

  3. Xcode - 添加文档注释插件

    Xcode自动添加文档注释插件: https://github.com/onevcat/VVDocumenter-Xcode 功能演示: 感谢onevcat的分享!

  4. 计算机人推荐书目&网站(不断更新)

    计算机人推荐书目&网站(不断更新) 鉴于最近有很多同学问我学什么读什么书好,我把我自己的经历和愚见写下来,仅供参考.我只会写我亲自读过有感悟的书,而不会搬运一些我碰都没有碰过只闻大名的书.本人 ...

  5. Shell:Day07.笔记

    函数:1.函数介绍function 为了避免代码重复使用,我们一般通过函数编写代码块,而这一个代码块用来实现某种功能. 且,这个功能在后面的代码中,会重复调用:  def 2.函数的语法格式 函数的写 ...

  6. Bitmap之内存缓存和磁盘缓存详解

    原文首发于微信公众号:躬行之(jzman-blog) Android 中缓存的使用比较普遍,使用相应的缓存策略可以减少流量的消耗,也可以在一定程度上提高应用的性能,如加载网络图片的情况,不应该每次都从 ...

  7. Android | 教你如何开发扫二维码功能

    前言   最近要做一个停车场扫码收费的app,在网上搜了一圈,首先接触到了ZXing,上手试了下,集成过程不复杂,但是感觉效果欠佳,比如距离稍微远点儿就扫不出来了,另外角度对的不好,反光或者光线比较暗 ...

  8. Git常用命令(一)

    $ git init 初始化仓库(会生成一个隐藏文件.git) $ git add + (文件名) 实现对指定文件的跟踪 $ git commit 提交更新$ git clone + URL 克隆远程 ...

  9. CVPR 2020论文收藏(转知乎:https://zhuanlan.zhihu.com/p/112337176)

    CVPR 2020 共收录 1470篇文章,根据当前的公布情况,人工智能学社整理了以下约100篇,分享给读者. 代码开源情况:详见每篇注释,当前共15篇开源.(持续更新中,可关注了解). 算法主要领域 ...

  10. uni-app的初识(01)

    1.什么是uni-app uni-app 是一个使用 Vue.js 开发所有前端应用的框架, 开发者编写一套代码, 可发布到IOS, Android, H5, 以及各种小程序(微信,百度)等多个平台. ...