#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的更多相关文章

  1. POJ 3923 HDU 2487 Ugly Windows 简单计算

    Ugly Windows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tot ...

  2. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  3. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  4. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  5. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  6. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  7. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  8. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  9. 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 ...

随机推荐

  1. 2018.06.27The Windy's(费用流)

    The Windy's Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 6003 Accepted: 2484 Descripti ...

  2. join和split 的使用

    var abc = new Array(a,b,c,d,e); abc.join('-') // 结果 : a-b-c-d-e-f var obk = 'a-b-c-d-e'; obk.split(' ...

  3. (13)How to stay calm when you know you'll be stressed

    https://www.ted.com/talks/daniel_levitin_how_to_stay_calm_when_you_know_you_ll_be_stressed/transcrip ...

  4. 轮询、中断、DMA和通道

    from http://blog.csdn.net/lastsweetop/article/details/3418769 一.轮询方式 对I/O设备的程序轮询的方式,是早期的计算机系统对I/O设备的 ...

  5. Mybatis-Plus 实战完整学习笔记(七)------select测试二

    1.查询selectOne  (3.0.3版) @Test public void selectMethod() throws SQLException { // 根据ID获取一个对象的数据 Empl ...

  6. 在多台PC之间同步Resharper所有设置的方法

    默认情况下Resharper只允许导出CodeStyle的设置,对于其它的设置不能导出,这样在不利用我们在多台PC之间同步Resharper的设置,经过多次尝试和Google找到了一种解决办法: Re ...

  7. 第15章:MongoDB-聚合操作--聚合管道--$match

    ①$match 用于对文档集合进行筛选,里面可以使用所有常规的查询操作符. 通常会放置在管道最前面的位置,理由如下: 1:快速将不需要的文档过滤,减少后续操作的数据量 2:在投影和分组之前做筛选,查询 ...

  8. UVaLive 3357 Pinary (Fib数列+递归)

    题意:求第 k 个不含前导 0 和连续 1 的二进制串. 析:1,10,100,101,1000,...很容易发现长度为 i 的二进制串的个数正好就是Fib数列的第 i 个数,因为第 i 个也有子问题 ...

  9. 后台开发 - DPDK引发的图谱

    关系图谱(点击看完整大图): 部分名词: 名词 全写 解释 备注 DPDK Data Plane Development Kit 数据平面开发套件或叫数据平面开发工具集 Intel开源的快速数据包处理 ...

  10. 1.4isAlive()方法

    方法isAlive()的功能是判断当前线程是否处于活动状态 活动状态是线程已经启动且尚未终止,线程处于正在运行或准备开始运行的状态,就认为线程是存活的. 测试如下 package com.cky.th ...