21612_Pump

2022-5-16 18:19| 发布者: Hocassian| 查看: 30| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505689032200-Problem List-采集的数据-后羿采集器.html

Pro.ID

21612

Title

Pump

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21612

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    There is something crazy! There is a pool and many of pumps to fill up the empty pool. We know that the capacity of each pump. And at last, we want you to tell us whether we can fill up the empty pool and the time we have to. And if we can't fill up the pool with all of the pumps, the least number of pumps we have to close.

    输入

    There are multiply test cases in this problem. In each test case, first line is a integer of n ( 1 ≤ n ≤ 15 ), which is the number of pumps. At the second line there are n integers ai ( 1 ≤ |ai| ≤ 10 ), which is the time (in hours) to fill up the empty pool ( ai > 0 ) or to empty the pool ( ai < 0 ).

    All the cases will be end with n=0.

    输出

    Description

    There is something crazy! There is a pool and many of pumps to fill up the empty pool. We know that the capacity of each pump. And at last, we want you to tell us whether we can fill up the empty pool and the time we have to. And if we can't fill up the pool with all of the pumps, the least number of pumps we have to close.

    Input

    There are multiply test cases in this problem. In each test case, first line is a integer of n ( 1 ≤ n ≤ 15 ), which is the number of pumps. At the second line there are n integers ai ( 1 ≤ |ai| ≤ 10 ), which is the time (in hours) to fill up the empty pool ( ai > 0 ) or to empty the pool ( ai < 0 ).

    All the cases will be end with n=0.

    Output

    If we can fill up the empty pool with all of the pump, print the hours (in integer) we have to use, otherwise print one line of "NO" and the least number we have to close up. At last, if we can't fill up the pool with some of the pumps closed, print one line of "Impossible".

    Sample Input

    2
    2 3
    2
    -2 3
    2
    -2 -2
    0

    Sample Output

    2
    NO 1
    Impossible

    Source

    样例输入

    2
    2 3
    2
    -2 3
    2
    -2 -2
    0

    样例输出

    2
    NO 1
    Impossible

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部