#4304. At Most 3 (Judge ver.)

0
    ID: 4304 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>AtCoderabc251BGESP 3级数组枚举(双层循环)

At Most 3 (Judge ver.)

At Most 3 (Judge ver.)

题目描述

There are NN weights called Weight 11, Weight 22, …\dots, Weight NN. Weight ii has a mass of AiA_i.
Let us say a positive integer nn is a good integer if the following condition is satisfied:

We can choose at most 33 different weights so that they have a total mass of nn.

How many positive integers less than or equal to WW are good integers?

输入格式

Input is given from Standard Input in the following format: NN WW A1A_1 A2A_2 …\dots ANA_N

输出格式

Print the answer.

2 10
1 3
3
2 1
2 3
0
4 12
3 3 3 3
3
7 251
202 20 5 1 4 2 100
48

提示

1≤N≤3001 \leq N \leq 300 1≤W≤1061 \leq W \leq 10^6 1≤Ai≤1061 \leq A_i \leq 10^6 All values in input are integers.If we choose only Weight 11, it has a total mass of 11, so 11 is a good integer.
If we choose only Weight 22, it has a total mass of 33, so 33 is a good integer.
If we choose Weights 11 and 22, they have a total mass of 44, so 44 is a good integer.
No other integer is a good integer. Also, all of 11, 33, and 44 are integers less than or equal to WW. Therefore, the answer is 33.
There are no good integers less than or equal to WW.
There are 33 good integers: 3,63, 6, and 99.
For example, if we choose Weights 11, 22, and 33, they have a total mass of 99, so 99 is a good integer.
Note that 1212 is not a good integer.

标签: AtCoder|abc251B

来源

AtCoder|abc251B