#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. fork、vfork、clone

    三个都是用来创建新进程的函数 fork 概念 1)fork函数调用一次会返回两次,给父进程返回子进程的进程ID,给子进程返回0(这么设计的原因:父进程可以有很多子进程,没有一个函数可以让父进程知道所有 ...

  2. java学习3创建学生属性:学号、姓名、电话 完全实现对象集合的增删改查。(控制台来做)

    首先创建一个student类其中包括get,set与构造函数 /** * */package work2; /** * @author Administrator * */public final c ...

  3. 链家web前端面试

    共有三轮面试,每个面试官的第一个问题都是:介绍一个你觉着比较出彩的项目 第一轮面试: 因为公司项目没什么亮点,很传统的pc端,美女面试官就说让讲一下我用react的私人项目; 问了很多都是关于reac ...

  4. highChart图表

    Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表,并且免费提供给个人学习.个人网站和非商业用途使用.HighCh ...

  5. js,javascript,获取地址栏参数

    function GetQueryString(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*) ...

  6. 学以致用五----centos7+python3.6.2+django2.1.1

    目的,在python 3.6的基础上搭建 django 2.x 一.使用pip安装django ,但是使用pip命令的时候报错,解决方法,做软连接 ln -s /usr/local/python/bi ...

  7. 在eclipse上搭建Roku开发环境

    环境:Oracle VM virtualBox+Ubuntu server 12.0.4.2 LTS+xfce+ Eclipse IDE for C/C++ Developers 4.3.2 参考:h ...

  8. nodejs mongodb 数据库封装DB类 -转

    使用到了nodejs的插件mongoose,用mongoose操作mongodb其实蛮方便的. 关于mongoose的安装就是 npm install -g mongoose 这个DB类的数据库配置是 ...

  9. openresty + lua 2、openresty 连接 redis,实现 crud

    redis 的话,openresty 已经集成,ng 的话,自己引入即可. github 地址:https://github.com/openresty/lua-resty-redis github  ...

  10. hdu 4941 map的使用

    http://acm.hdu.edu.cn/showproblem.php?pid=4941 给定N,M和K,表示在一个N*M的棋盘上有K个棋子,给出K个棋子的位置和值,然后是Q次操作,对应的是: 1 ...