#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. hdu-1255(线段树求面积并)模板

    题目链接:传送门 思路: (1)建立线段的信息,每个线段存储l到r的线段的x位置和y的起始点与终点. 建立线段树的节点信息,每个节点代表一个区间的信息,x表示区间的横坐标的位置,l,r表示纵坐标的范围 ...

  2. Linux入门(1)——Ubuntu16.04安装搜狗拼音

    在网址下载搜狗deb包:http://pinyin.sogou.com/linux/ 将下载的sogoupinyin_2.1.0.0082_amd64.deb放在根目录下. 安装搜狗拼音: ltq@l ...

  3. 敏捷项目管理工具-Trello(电子看板)

    Trello简介(https://www.trello.com) A Trello board is a list of lists, filled with cards, used by you a ...

  4. bzoj2938(ac自动机)

    刚学了ac自动机,去hzwer上找了道练习题: 串是安全的就说明ac自动机不会找到匹配,考虑ac自动机的匹配过程: 我们把val等于1的点删掉和fail指针指向被删掉的点删掉: 如果剩下的图有环,就有 ...

  5. c#运用反射获取属性和设置属性值

    /// <summary> /// 获取类中的属性值 /// </summary> /// <param name="FieldName">&l ...

  6. Northwind测试学习用数据库

    下载地址: https://northwinddatabase.codeplex.com/

  7. Java相关工具下载、配置环境变量

    相关工具下载 JDK:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Eclip ...

  8. hihocoder 二分

    题目 一个简单的二分,只是想说明一下,如若要查找一个数组中某个数的下标可以直接用lower_bound()这个函数.只是要考虑到要查找的数不在数组中的这种情况. #include <cstdio ...

  9. [smarty] smarty 模板文件中进行字符串与变量的拼接

    // smarty 模板引擎 $arr_tribeLabelList["`$tribe_id`_"]

  10. delphi IsIPAdress 非正则表达式验证IP的方法

    function IsIPAdress(const Value:String):Boolean; var n,x,i: Integer; Posi:Array[..]of Integer; Oktet ...