#include <bits/stdc++.h>
using namespace std;
int n, l, x;
const int MOD = 1e9 + 7;
int nCr[30500][500];
int dp[2][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 & 1][j][k] = 0;
if (2 * arr[i] - 1 <= j) dp[i & 1][j][k] = add(dp[i & 1][j][k], mul(mul(k + 1, k), dp[(i & 1) ^ 1][j - 2 * arr[i] + 1][k + 1]));
dp[i & 1][j][k] = add(dp[i & 1][j][k], dp[(i & 1) ^ 1][j - 1][k - 1]);
if (arr[i] <= j) dp[i & 1][j][k] = add(dp[i & 1][j][k], mul(2 * k, dp[(i & 1) ^ 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 & 1][i][1], nCr[n - i + l][n]));
cout << sum << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
66896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
66788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
62812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
66896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |