POJ 2487
#include<iostream>
#include<stdio.h>
using namespace std; int compare(void const * i,void const * j);
int main()
{
//freopen("acm.acm","r",stdin);
int num;
int i;
int j;
int st;
int sum;
int f_num;
int * a;
cin>>num;
j = ;
while(num --)
{
cin>>st;
cin>>f_num;
sum = ;
a = new int[f_num];
for(i = ; i < f_num; ++ i)
{
cin>>a[i];
}
qsort(a,f_num,sizeof(int),compare);
for(i = ; i < f_num; ++ i)
{
sum += a[i];
if(sum >= st)
{
cout<<"Scenario #"<<j<<":"<<endl;
cout<<i+<<endl;
++j;
cout<<endl;
break;
}
}
if(i == f_num)
{
cout<<"Scenario #"<<j<<":"<<endl;
cout<<"impossible"<<endl;
++ j;
cout<<endl;
}
delete[] a; }
}
int compare(void const * i,void const * j)
{
return *((int *)j) - *((int *)i);
}
POJ 2487的更多相关文章
- POJ 3923 HDU 2487 Ugly Windows 简单计算
Ugly Windows Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- POJ 2752 Seek the Name, Seek the Fame [kmp]
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
随机推荐
- 2018.11.09 bzoj1706: relays 奶牛接力跑(倍增+floyd)
传送门 倍增+floyd板子题. 先列出状态fi,j,kf_{i,j,k}fi,j,k表示经过iii条边从jjj到kkk的最短路. 然后发现可以用fi−1,j,kf_{i-1,j,k}fi−1,j, ...
- WEB应用支持RESTFUL风格方法
REST概念 Restful就是一个资源定位及资源操作的风格.不是标准也不是协议,只是一种风格.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制. REST风格 资源:互联网所有的事物 ...
- 使用express框架和mongoose在MongoDB查找数据
1.创建Schema var schema = new mongoose.Schema({ userName:{type:String,require:true}, age:{type:Number, ...
- hadoop Mapreduce组件介绍
MapReduce原理 MapRedcue采用‘分而治之’的思想,对大规模数据集的操作,分发给一个主节点下的各个分节点共同完成,然后通过整合各个节点的中间结果,得到最终结果.Mapreduce就是任务 ...
- MySQL在线大表DDL操作
在线大表DDL操作的方法: 1.主从架构轮询修改 需要注意: a.主库会话级别的记录binglog的参数关闭 b.500\502错误异常捕捉 c.检查备库的second behind master是否 ...
- 2.3.1关键字volatile与死循环
关键字volatile的主要作用是使变量在多个线程间可见. 测试如下 package com.cky.test; /** * Created by edison on 2017/12/9. */ pu ...
- python的基础socket知识
对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. 代码意思if __name__ == '__main__':是主文件的话就先执行main函数, ...
- 终端简单使用 &vim编写代码
vim简单实用 & 用vim编写代码 ## 简单介绍 ## vi 1.c 建立1.c(文件存在,则打开1.c) vi共有三种模式: 按esc进入指令模式 按i进入编辑模式(按i光标位置不变 ...
- 74(2B)Shortest Path (hdu 5636) (Floyd)
Shortest Path Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- Codeforces821A Okabe and Future Gadget Laboratory 2017-06-28 14:55 80人阅读 评论(0) 收藏
A. Okabe and Future Gadget Laboratory time limit per test 2 seconds memory limit per test 256 megaby ...