1494. Coins

单点时限: 2.0 sec

内存限制: 256 MB

People in Silverland use coins. They have coins of value $A_1,A_2,A_3,\ldots,A_n$ Silverland dollar. One day Tony opened his money-box and found there were some coins. He decided to buy a very nice watch in a nearby shop. He wanted to pay the exact price (without change) and he known the price would not more than $m$. But he didn’t know the exact price of the watch.

You are to write a program which reads $n,m,A_1,A_2,A_3,\ldots,A_n$ and $C_1,C_2,C_3,\ldots,C_n$ corresponding to the number of Tony’s coins of value $A_1,A_2,A_3,\ldots,A_n$ then calculate how many prices (from $1$ to $m$) Tony can pay use these coins.

输入格式

The first line of test case contains two integers $n$ $(1 \le n \le 100)$, $m$ $(m \le 100~000)$. The second line contains $2n$ integers, denoting $A_1,A_2,A_3,\ldots,A_n,C_1,C_2,C_3,\ldots,C_n$ $(1 \le A_i \le 100~000, 1 \le Ci \le 1000)$.

输出格式

Output the answer on a single line.

样例

Input
2 5
1 4 2 1
Output
4

42 人解决,54 人已尝试。

59 份提交通过,共有 166 份提交。

4.1 EMB 奖励。

创建: 17 年,4 月前.

修改: 7 年,1 月前.

最后提交: 1 年,5 月前.

来源: LouTiancheng

题目标签
DP