--hdu 2124 Repair the Wall(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2124

Ac code :
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
return *(int *)b-*(int *)a;
}
int main()
{
int L, N, i;
int a[601], sum, len;
while(scanf("%d",&L)!=EOF)
{
scanf("%d",&N);
for(i = 0; i < N; i++)
scanf("%d",&a[i]);
qsort(a, N, sizeof(a[0]), cmp);
sum = len = 0;
for(i = 0; i < N; i++)
{
if(len < L)
{
len += a[i];
sum++;
}
else
break;
}
if(len < L)
printf("impossible\n");
else
printf("%d\n",sum);
}
return 0;
}
--hdu 2124 Repair the Wall(贪心)的更多相关文章
- HDU 2124 Repair the Wall
http://acm.hdu.edu.cn/showproblem.php?pid=2124 Problem Description Long time ago , Kitty lived in a ...
- 杭电 2124 Repair the Wall(贪心)
Description Long time ago , Kitty lived in a small village. The air was fresh and the scenery was ve ...
- 简单贪心) Repair the Wall hdu2124
Repair the Wall http://acm.hdu.edu.cn/showproblem.php?pid=2124 Time Limit: 5000/1000 MS (Java/Others ...
- HDU2124 Repair the Wall(贪心)
Problem Description Long time ago , Kitty lived in a small village. The air was fresh and the scener ...
- Repair the Wall (贪心)
Long time ago , Kitty lived in a small village. The air was fresh and the scenery was very beautiful ...
- hdu 3669 Cross the Wall(斜率优化DP)
题目连接:hdu 3669 Cross the Wall 题意: 现在有一面无限大的墙,现在有n个人,每个人都能看成一个矩形,宽是w,高是h,现在这n个人要通过这面墙,现在只能让你挖k个洞,每个洞不能 ...
- Repair the Wall
问题 : Repair the Wall 时间限制: 1 Sec 内存限制: 128 MB 题目描述 Long time ago , Kitty lived in a small village. ...
- hdu 4825 Xor Sum(trie+贪心)
hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include ...
- HDU 5813 Elegant Construction (贪心)
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...
随机推荐
- [转]在Ubuntu 下安装Redis 并使用init 脚本启动
1. 下载安装: cd /tmp wget http://redis.googlecode.com/files/redis-2.2.4.tar.gz tar -zxf redis-2.2.4.ta ...
- WAC集中转发部署
1,背景: sta属于vlan20.ap属于vlan20.本地转发. 现象: Ap获取到的地址是vlan20的地址池的某地址 用户无法获取地址. 注意:本地转发,ap获取地址dhcp包不走隧道.用户获 ...
- Linux 网络编程九(select应用--大并发处理)
//网络编程服务端 /* * 备注:因为客户端代码.辅助方法代码和epoll相同,所以select只展示服务器端代码 */ #include <stdio.h> #include < ...
- 集锦.txt
不同的时代,有不同的需要以前,我们都以为自己可以为爱情去死,可是后来爱情死了,我们还活着. 小时候男孩子喜欢电动玩具,女孩子喜欢娃娃.长大了男孩子喜欢娃娃,女孩子喜欢电动玩具.也许这就是成长吧! 我大 ...
- int 与Integer的用法与区别
1.int是基本类型,直接存取数值,Integer是对象,用一个引用指向这个对象. 2.java中的数据类型分为基本数据类型和复杂数据类型,int是前者,Integer是后者(也就是一个类). 3.初 ...
- (OAF)jdeveloper集成log4j并将日志输出到指定文件并写入数据库
参考: How to configure Log4j in JDev 11g Ever wanted to use log4j in your adf project ? Well though Or ...
- cookie+memcached实现单点登陆
10年的时候在iteye的第一篇文章记录了一下当时怎么实现我们系统的单点登陆.不过那个时候文章写的不好,思路也很浮躁,很难看懂,在csdn的第一篇技术博客打算重新温顾一下当时实现单点登陆的思路.先来看 ...
- Android -- 创建数据库到SD卡
SQLite 系统自带的SQLite是通过SQLiteOpenHelper实现的,而SQLiteOpenHelper是将数据库存储到/data/data/包名/databasas,这样做的话在没有ro ...
- 解决方法:未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序
win7或win8 64位调试程序,出现这样的错误提示:未在本地计算机上注册 Microsoft.Jet.OLEDB.4.0 提供程序 解决方法如下: 方法一:“设置应用程序池默认属性”/“常规”/” ...
- JSONProxy - 获取跨域json数据工具
JSONProxy是一款很好的获取json数据的代理网站,“Enables cross-domain requests to any JSON API”.当你苦于无法跨域获取json数据时,不妨一试, ...