#include <bits/stdc++.h>
using namespace std;
int n, l, x;
const int MOD = 1e9 + 7;
int nCr[30500][500];
int dp[50][100001][51];
int add (int a, int b) {
a += b; if (a >= MOD) a -= MOD;
return a;
}
int sub (int a, int b) {
a -= b; if (a < 0) a += MOD;
return a;
}
int mul (int a, int b) {
return (a * 1ll * b) % MOD;
}
int arr[51];
int main () {
cin >> n >> l;
for (int i = 0; i < 30500; i++) {
for (int j = 0; j <= min(499, i); j++) {
if (j == 0 || j == i) {
nCr[i][j] = 1;
} else {
nCr[i][j] = add(nCr[i - 1][j], nCr[i - 1][j - 1]);
}
}
}
for (int i = 1; i <= n; i++) cin >> arr[i];
sort(arr + 1, arr + n + 1);
dp[0][0][0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= l; j++) {
for (int k = 1; k <= i; k++) {
dp[i][j][k] = 0;
if (2 * arr[i] - 1 <= j) dp[i][j][k] = add(dp[i][j][k], mul(mul(k + 1, k), dp[i - 1][j - 2 * arr[i] + 1][k + 1]));
dp[i][j][k] = add(dp[i][j][k], dp[i - 1][j - 1][k - 1]);
if (arr[i] <= j) dp[i][j][k] = add(dp[i][j][k], mul(2 * k, dp[i - 1][j - arr[i]][k]));
//cout << i << " " << j << " " << k << ": " << dp[i][j][k] << '\n';
}
}
}
//for (int i = 1; i <= l; i++) cout << dp[n][i][1] << '\n';
int sum = 0;
for (int i = 1; i <= l; i++) sum = add(sum, mul(dp[n][i][1], nCr[n - i + l][n]));
cout << sum << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
253708 KB |
Output is correct |
2 |
Correct |
32 ms |
161248 KB |
Output is correct |
3 |
Correct |
33 ms |
99712 KB |
Output is correct |
4 |
Correct |
24 ms |
76880 KB |
Output is correct |
5 |
Correct |
30 ms |
114012 KB |
Output is correct |
6 |
Correct |
50 ms |
165200 KB |
Output is correct |
7 |
Correct |
49 ms |
204112 KB |
Output is correct |
8 |
Correct |
24 ms |
63068 KB |
Output is correct |
9 |
Correct |
36 ms |
161120 KB |
Output is correct |
10 |
Correct |
22 ms |
62808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
99624 KB |
Output is correct |
2 |
Correct |
23 ms |
68908 KB |
Output is correct |
3 |
Correct |
28 ms |
99660 KB |
Output is correct |
4 |
Correct |
25 ms |
75100 KB |
Output is correct |
5 |
Correct |
28 ms |
99624 KB |
Output is correct |
6 |
Correct |
24 ms |
77136 KB |
Output is correct |
7 |
Correct |
29 ms |
99664 KB |
Output is correct |
8 |
Correct |
24 ms |
81232 KB |
Output is correct |
9 |
Correct |
24 ms |
77148 KB |
Output is correct |
10 |
Correct |
23 ms |
64848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
122196 KB |
Output is correct |
2 |
Correct |
26 ms |
101720 KB |
Output is correct |
3 |
Correct |
28 ms |
122196 KB |
Output is correct |
4 |
Correct |
28 ms |
103772 KB |
Output is correct |
5 |
Correct |
31 ms |
122364 KB |
Output is correct |
6 |
Correct |
26 ms |
99676 KB |
Output is correct |
7 |
Correct |
29 ms |
122192 KB |
Output is correct |
8 |
Correct |
28 ms |
81044 KB |
Output is correct |
9 |
Correct |
26 ms |
103780 KB |
Output is correct |
10 |
Correct |
24 ms |
81140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
253708 KB |
Output is correct |
2 |
Correct |
32 ms |
161248 KB |
Output is correct |
3 |
Correct |
33 ms |
99712 KB |
Output is correct |
4 |
Correct |
24 ms |
76880 KB |
Output is correct |
5 |
Correct |
30 ms |
114012 KB |
Output is correct |
6 |
Correct |
50 ms |
165200 KB |
Output is correct |
7 |
Correct |
49 ms |
204112 KB |
Output is correct |
8 |
Correct |
24 ms |
63068 KB |
Output is correct |
9 |
Correct |
36 ms |
161120 KB |
Output is correct |
10 |
Correct |
22 ms |
62808 KB |
Output is correct |
11 |
Correct |
29 ms |
99624 KB |
Output is correct |
12 |
Correct |
23 ms |
68908 KB |
Output is correct |
13 |
Correct |
28 ms |
99660 KB |
Output is correct |
14 |
Correct |
25 ms |
75100 KB |
Output is correct |
15 |
Correct |
28 ms |
99624 KB |
Output is correct |
16 |
Correct |
24 ms |
77136 KB |
Output is correct |
17 |
Correct |
29 ms |
99664 KB |
Output is correct |
18 |
Correct |
24 ms |
81232 KB |
Output is correct |
19 |
Correct |
24 ms |
77148 KB |
Output is correct |
20 |
Correct |
23 ms |
64848 KB |
Output is correct |
21 |
Correct |
29 ms |
122196 KB |
Output is correct |
22 |
Correct |
26 ms |
101720 KB |
Output is correct |
23 |
Correct |
28 ms |
122196 KB |
Output is correct |
24 |
Correct |
28 ms |
103772 KB |
Output is correct |
25 |
Correct |
31 ms |
122364 KB |
Output is correct |
26 |
Correct |
26 ms |
99676 KB |
Output is correct |
27 |
Correct |
29 ms |
122192 KB |
Output is correct |
28 |
Correct |
28 ms |
81044 KB |
Output is correct |
29 |
Correct |
26 ms |
103780 KB |
Output is correct |
30 |
Correct |
24 ms |
81140 KB |
Output is correct |
31 |
Correct |
105 ms |
253780 KB |
Output is correct |
32 |
Correct |
78 ms |
216664 KB |
Output is correct |
33 |
Correct |
116 ms |
253372 KB |
Output is correct |
34 |
Correct |
51 ms |
153032 KB |
Output is correct |
35 |
Correct |
99 ms |
253524 KB |
Output is correct |
36 |
Correct |
30 ms |
107860 KB |
Output is correct |
37 |
Correct |
107 ms |
253616 KB |
Output is correct |
38 |
Correct |
41 ms |
169340 KB |
Output is correct |
39 |
Incorrect |
98 ms |
253520 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |