#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 105, L = 1005, MD = 1e9 + 7;
void add(int &a, int b) {
if ((a += b) >= MD) {
a -= MD;
}
}
int n, l;
int a[N], dp[N][N][L][3];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> l;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
a[n + 1] = 10000;
dp[0][0][0][0] = 1;
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= i; ++j) {
for (int k = 0; k <= l; ++k) {
for (int m = 0; m < 3; ++m) {
int dif = (a[i + 1] - a[i]) * (2 * j - m);
int &res = dp[i][j][k][m];
if (dif <= k && i + j + 1 - m <= n) {
add(res, dp[i - 1][j - 1][k - dif][m]);
add(res, (long long) (2 * j - m) * dp[i - 1][j][k - dif][m] % MD);
if (m > 0) {
add(res, (long long) (3 - m) * dp[i - 1][j - 1][k - dif][m - 1] % MD);
if (m == 1) {
add(res, 2LL * j * dp[i - 1][j][k - dif][m - 1] % MD);
} else {
if (i == n) {
if (j == 1) {
add(res, dp[i - 1][j][k - dif][m - 1]);
}
} else {
add(res, (long long) (j - 1) * dp[i - 1][j][k - dif][m - 1] % MD);
}
}
}
if (m == 2) {
if (i == n) {
add(res, dp[i - 1][j + 1][k - dif][m]);
} else {
add(res, (long long) j * (j - 1) * dp[i - 1][j + 1][k - dif][m] % MD);
}
} else if (m == 1) {
add(res, (long long) j * j * dp[i - 1][j + 1][k - dif][m] % MD);
} else {
add(res, (long long) j * (j + 1) * dp[i - 1][j + 1][k - dif][m] % MD);
}
}
}
}
}
}
int res = 0;
for (int k = 0; k <= l; ++k) {
add(res, dp[n][1][k][2]);
}
cout << res;
return 0;
}
// Thanks Usaco!!!
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |