--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 ...
随机推荐
- Got a packet bigger than 'max_allowed_packet' bytes
昨天用导入数据的时候发现有的地方有这个错误.后来才发现我用RPM包装的MYSQL配置文件里面有old_passwords=1去掉就可以了. Got a packet bigger than ‘max_ ...
- LINQ to Entities 查询语法
转自: http://www.cnblogs.com/asingna/archive/2013/01/28/2879595.html 实体框架(Entity Framework )是 ADO.NET ...
- [CareerCup] 5.1 Insert Bits 插入位
5.1 You are given two 32-bit numbers, N and M, and two bit positions, land j. Write a method to inse ...
- 启动页面设置,icon图标设置
更多尺寸像素如何放置请看:http://chicun.jammy.cc/ 如何设置App的启动图,也就是Launch Image? 新建一个iosLaunchImage文件夹
- Jenkins进阶系列之——12详解Jenkins节点配置
2014-03-02:修正对于lable标签的理解.(1.532.1版本已经给出了官方解释) 2013-12-22:添加JNLP端口修改,修改了一些错误. Jenkins有个很强大的功能:分布式构建( ...
- 深入探索Java 8 Lambda表达式
2014年3月,Java 8发布,Lambda表达式作为一项重要的特性随之而来.或许现在你已经在使用Lambda表达式来书写简洁灵活的代码.比如,你可以使用Lambda表达式和新增的流相关的API,完 ...
- Xamarin.Forms 现已开启对 UWP 的支持
Xamarin.Forms 现已升级到 2.0.0.6482 , 正式开启了对 UWP 的支持. 要创建 UWP 项目, 必须是 VS2015, WIN8.1 下也可以, 但是只有 Windows 1 ...
- Android中图片大小和屏幕密度的关系讲解
Android手机适配是非常让人头疼的一件事,尤其是图片,android为了做到是适配提供了很多文件夹来存放不同大小的图片,比如:drawable-ldpi.drawable-mdpi.drawabl ...
- android之文件权限问题
当我们在手机上安装一个应用的时候,linux会为每个APP创建一个用户名和用户组 xidian.dy.com.chujia是系统为每个应用创建的一个独立的文件夹,我们可以看到这个文件的所有者为app_ ...
- 《TCP/IP详解卷1:协议》第5章 RARP:逆地址解析协议-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...