Pro.ID21612 TitlePump Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21612 AC0 Submit0 Ratio- 时间&空间限制描述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 Sample Output 2 Source 样例输入2 样例输出2 作者 |