CELEBRATION TIME

3.7

19 votes
Problem

It's the time of JANMASHTAMI and we here at codify are in a celebration mood , and as a coding enthusiast , our president ALICE and BOB have thought of distributing ladoos (their favourite sweet). Alice gave Bob few containers that can contain specific kilograms of ladoos and a list of people along with the amount of ladoos that need to be delivered to the guest . Now Bob task is to choose wisely the containers such that he can he can take away the amount to be delivered with the minimum number of containers. Help BOB with his task.

INPUT

First line contain T(T=Number of test cases)

Second line contain W(W= weight of ladoos need to delivered)

Third line contain M(M= Number of containers)

Next ' M ' lines follows maximum weight a container can hold.

NOTE1:- If you are using a container you have to use it to the full capacity. You can't use container partially.

NOTE2:- You can use same container more than once.(For more explanation see the test cases)

OUTPUT

Minimum number of container required.

CONSTRAINTS:-

1<=T<=10

1<=W<=1000

1<=M<=8

TEST CASE #1

1

10

4

2 5 3 7

OUTPUT

2

Explanation: You can pick 3rd and 4th container to get 10 . So,total container required is 2.

TEST CASE #2

1

3

4

1 5 4 6

OUTPUT

3

Explanation: You can pick 1st container 3 times to get 3 . So,total container required is 3.

Sample Input
1

10

4

2 5 3 7
Sample Output
2
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?