Geeksforgeeks

Timer is Running

Charul has been given a task by Ishaan. He challenges him to fill a large container of capacity K litres. Charul has N vessels with him with diiferent capacities.

The capacities of the vessels are given by an array A. The condition is that the container should be filled upto the brim but no water should be wasted in overflowing. Also, the vessels can't be filled partially.

Determine if Charul can fill up the container with the given conditions or not.

Assume that Charul has unlimited supply of water.

**Input :**

First line of input contains a single integer T denoting the number of test cases.

The first line of each test case contains 2 space-separated integers N and K.

The second line contains N space-separated integers denoting the array A.

**Output :**

For each test case, print "1" if it is possible, else print "0" in a new line (without quotes "").

**Constraints :**

1 <= T <= 100

1 <= N <= 100

1 <= K <= 10^3

1 <= A[i] <= 100

**Example :
Input :**

3

5 20

6 3 4 2 1

3 15

2 4 3

4 10

8 3 12 6

1

1

0

**Explanation : **

Case 1 :

The container can be filled in the following manner :

Add water using the 6 litre vessel 3 times : Container filled upto 18 litres

Add water using the 2 litre vessel 1 time : Container filled upto 20 litres

Case 2 :

The container can be filled in the following manner :

Add water using the 3 litre vessel 5 times : Container filled upto 15 litres

Case 3 :

The container can't be filled upto 10 litres using the given vessels.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

jainshubham52535 | 529 |

Pathak1899 | 436 |

yashdip123 | 380 |

kirtidee18 | 377 |

jots62 | 351 |

kirtidee18 | 1057 |

ykaushik | 752 |

aggarwalvatsal5 | 741 |

harbilassingh | 576 |

pmr_3689 | 570 |

blackshadows | 5456 |

Ibrahim Nash | 5450 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4827 |

Login to report an issue on this page.