#P1164. 小A点菜

    ID: 164 远端评测题 1000ms 512MiB 尝试: 3 已通过: 2 难度: 3 上传者: 标签>动态规划,dp搜索洛谷原创背包

小A点菜

Description

However, because uim bought some books, he has only MM yuan left (0<M10000)(0 < M \le 10000).

Although the restaurant is low-end, it still has NN kinds of dishes (1N100)(1 \le N \le 100). The ii-th dish costs aia_i yuan (0<ai1000)(0 < a_i \le 1000). Since it is a very low-end restaurant, there is only one portion of each dish.

Xiao A follows the rule of “not stopping until all the money is spent,” so he will order in such a way that the total cost is exactly all the money uim has. He wants to know how many different ways to order.

Because Xiao A is too hungry, he can wait at most 11 second.

Input Format

The first line contains two integers NN and MM, representing the number of dishes and the amount of money uim has.

The second line contains NN positive integers aia_i (possibly with duplicates), separated by spaces, representing the price of each dish.

Output Format

Output a single positive integer, the number of ordering plans. It is guaranteed that the answer is in the range [0,2311][0, 2^{31}-1] (does not exceed the C/C++ int range).

4 4
1 1 2 2

3

Hint

2020.8.29, added a set of hack testdata by @yummy.

Translated by ChatGPT 5