题目1436:Repair the Wall 九度OJ
来源:互联网 发布:数据精灵免费版 编辑:程序博客网 时间:2024/06/10 02:14
#include <cstdio> #include <iostream>#include <algorithm>using namespace std;int blocks[605];bool cmp(int a,int b){return a>b;}int main(){int l,n;while(scanf("%d%d",&l,&n)!=EOF){for(int i=0;i<n;i++){scanf("%d",&blocks[i]);}sort(blocks,blocks+n,cmp);int currentl=l,num=0,flag=0;for(int i=0;i<n;i++){currentl-=blocks[i];num++;if(currentl<=0){flag=1;break;}}if(flag==0){printf("impossible\n");}else{printf("%d\n",num);}}return 0;}
0 0
- 题目1436:Repair the Wall 九度OJ
- 九度OJ-1436-Repair the Wall
- 九度题目1436:Repair the Wall
- 九度 题目1436:Repair the Wall
- 题目1436:Repair the Wall
- 题目1436:Repair the Wall
- 题目1436:Repair the Wall
- 题目1436:Repair the Wall
- 题目1436:Repair the Wall
- 九度考研机试教程 24-题目1436:Repair the Wall
- 24-题目1436:Repair the Wall
- 题目24:Repair the Wall
- 题目24:Repair the Wall
- 【HDU-oj】-2124-Repair the Wall(贪心)
- hdu2124 Repair the Wall
- Repair the Wall+贪心
- Repair the Wall
- 2124:Repair the Wall
- TCP超时与重传
- GCJ Qualification Round 2017
- Python之高级函数
- PS制作GIF 动画
- 交叉编译boa后在开发板运行boa出现-/bin/sh: boa: not found 错误的解决方法
- 题目1436:Repair the Wall 九度OJ
- 递推递归-M-数值分解
- 字典树模板
- Java 网络IO编程总结(BIO、NIO、AIO均含完整实例代码)
- 设计模式(四)-工厂模式-简单工厂
- 剑指offer-调整数组顺序使奇数位于偶数前面
- 内核探测工具systemtap简介
- Ubuntu下编译linux-0.00
- VMwarePro 12教程 简洁明快不装逼 快速学会使用虚拟机