#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<ll, int> ii;
const int mod = (int) 1e9 + 7;
const ll inf = 1LL << 60;
const int maxn = (int) 105;
const ld eps = 1e-9;
void add(int &a, ll b) {
b %= mod;
a += b;
while (a >= mod) a -= mod;
}
int n, L, a[maxn];
int f[2][maxn][maxn * 10][3];
int main() {
//freopen("test.txt", "r", stdin);
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> L;
rep(i, 1, n + 1) cin >> a[i];
sort(a + 1, a + 1 + n);
a[n + 1] = 12345;
if(a[2] - a[1] <= L) f[1][1][a[2] - a[1]][1] = 2;
if(2 * (a[2] - a[1]) <= L) f[1][1][2 * (a[2] - a[1])][0] = 1;
rep(i, 1, n) {
int d = a[i + 2] - a[i + 1];
rep(j, 1, i + 1) {
rep(k, 0, L + 1) {
rep(e, 0, min(j + 1, 3)) {
if(!f[i & 1][j][k][e]) continue;
if(e < 2) {
if(k + (2 * (j + 1) - (e + 1)) * d <= L)
add(f[(i + 1) & 1][j + 1][k + (2 * (j + 1) - (e + 1)) * d][e + 1], (2 - e) * f[i & 1][j][k][e]);
if(k + (2 * j - (e + 1)) * d <= L)
add(f[(i + 1) & 1][j][k + (2 * j - (e + 1)) * d][e + 1], (2 - e) * f[i & 1][j][k][e]);
}
if(k + (2 * (j + 1) - e) * d <= L)
add(f[(i + 1) & 1][j + 1][k + (2 * (j + 1) - e) * d][e], 1LL * (j - e + 1) * f[i & 1][j][k][e]);
if(k + (2 * j - e) * d <= L)
add(f[(i + 1) & 1][j][k + (2 * j - e) * d][e], 1LL * (2 * j - e) * f[i & 1][j][k][e]);
if(j > 1 && k + (2 * (j - 1) - e) * d <= L)
add(f[(i + 1) & 1][j - 1][k + (2 * (j - 1) - e) * d][e], 1LL * (j - 1) * f[i & 1][j][k][e]);
}
}
}
memset(f[i & 1], 0, sizeof f[i & 1]);
}
int res = 0;
rep(i, 0, L + 1) add(res, f[n & 1][1][i][2]);
cout << res << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
4764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4764 KB |
Output is correct |
2 |
Correct |
0 ms |
4764 KB |
Output is correct |
3 |
Correct |
0 ms |
4764 KB |
Output is correct |
4 |
Correct |
0 ms |
4764 KB |
Output is correct |
5 |
Correct |
0 ms |
4764 KB |
Output is correct |
6 |
Correct |
0 ms |
4764 KB |
Output is correct |
7 |
Correct |
0 ms |
4764 KB |
Output is correct |
8 |
Correct |
0 ms |
4764 KB |
Output is correct |
9 |
Correct |
0 ms |
4764 KB |
Output is correct |
10 |
Correct |
0 ms |
4764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
4764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |