Submeter | Todas submissőes | Melhores | Voltar |
Problem hidden
CODEM5 - Problem5 |
You are given an array of weights of n objects and your task is to select minimum number of objects whose sum of weights is exactly equals to some given k.
Input
Line 1 - number of test cases T (≤ 10) followed by 2 lines for each test case
Line 2 - Number of objects n (≤ 100) and total weight k (≤ 104)
Line 3 - weights (≤ 104) of n objects (each separated by space)
Output
Minimum number of objects whose weights sums to k.
Example
Input: 2
5 9
10 9 4 3 5
3 7
1 2 3 Output: 1
impossible
Explanation
For the first case the two combinations are possible: (9), (4, 5) hence minimum number of objects is 1.
For the second case there are no combinations possible hence impossible.
Adicionado por: | Bhavik |
Data: | 2014-02-04 |
Tempo limite: | 5s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | Todas exceto: ASM64 CLOJURE ERL FSHARP PERL6 PY_NBC SCALA TCL |
Origem: | own problem(for CODE MARATHON) |