/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
高橋君は N 個のアイテムを持っています。アイテムには 1 から N までの番号がつけられており、アイテム i の価値は A_i です。
高橋君は持ち物を整理するため、N 個のアイテムの中から相異なる K 個を選んで手放し、残りの N - K 個を手元に残すことにしました(K = 0 の場合はアイテムを 1 つも手放さず、すべてのアイテムを手元に残します)。
手元に残るアイテムの価値の総和が X 以上となるような手放すアイテムの選び方の個数を、998244353 で割った余りを求めてください。
ただし、手元に残るアイテムが 0 個である場合(K = N の場合)、その価値の総和は 0 とみなします。また、2 つの選び方は、手放すアイテムの番号の集合が異なるときに区別されます。
制約
- 1 \leq N \leq 100
- 0 \leq K \leq N
- 0 \leq X \leq 5000
- 1 \leq A_i \leq 50 (1 \leq i \leq N)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K X A_1 A_2 \dots A_N
出力
条件を満たす手放すアイテムの選び方の個数を 998244353 で割った余りを 1 行に出力せよ。
入力例 1
4 2 5 1 2 3 4
出力例 1
4
入力例 2
3 1 20 2 3 5
出力例 2
0
入力例 3
10 3 120 15 22 8 41 33 19 50 12 27 38
出力例 3
120
入力例 4
100 50 1200 25 43 12 37 8 49 16 33 28 5 40 19 44 2 31 50 11 23 39 14 47 6 35 21 48 17 30 9 42 27 3 38 15 46 20 32 1 26 45 10 24 36 13 41 7 50 18 34 29 4 22 43 12 37 8 49 16 33 28 5 40 19 44 2 31 50 11 23 39 14 47 6 35 21 48 17 30 9 42 27 3 38 15 46 20 32 1 26 45 10 24 36 13 41 7 50 18 34 29 4
出力例 4
739759542
入力例 5
1 1 0 1
出力例 5
1
Score : 400 pts
Problem Statement
Takahashi has N items. The items are numbered 1 through N, and the value of item i is A_i.
To organize his belongings, Takahashi decided to choose K distinct items from the N items to discard, keeping the remaining N - K items. (If K = 0, he discards no items and keeps all of them.)
Find the number of ways to choose the items to discard such that the sum of the values of the remaining items is at least X, modulo 998244353.
Here, if 0 items remain (i.e., when K = N), the sum of their values is considered to be 0. Also, two ways of choosing items are distinguished if the sets of the indices of the discarded items are different.
Constraints
- 1 \leq N \leq 100
- 0 \leq K \leq N
- 0 \leq X \leq 5000
- 1 \leq A_i \leq 50 (1 \leq i \leq N)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K X A_1 A_2 \dots A_N
Output
Print the number of ways to choose the items to discard that satisfy the condition, modulo 998244353, in a single line.
Sample Input 1
4 2 5 1 2 3 4
Sample Output 1
4
Sample Input 2
3 1 20 2 3 5
Sample Output 2
0
Sample Input 3
10 3 120 15 22 8 41 33 19 50 12 27 38
Sample Output 3
120
Sample Input 4
100 50 1200 25 43 12 37 8 49 16 33 28 5 40 19 44 2 31 50 11 23 39 14 47 6 35 21 48 17 30 9 42 27 3 38 15 46 20 32 1 26 45 10 24 36 13 41 7 50 18 34 29 4 22 43 12 37 8 49 16 33 28 5 40 19 44 2 31 50 11 23 39 14 47 6 35 21 48 17 30 9 42 27 3 38 15 46 20 32 1 26 45 10 24 36 13 41 7 50 18 34 29 4
Sample Output 4
739759542
Sample Input 5
1 1 0 1
Sample Output 5
1