#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100+1, L = 1000+1, mod = 1e9+7;
int n, l;
int a[N];
ll dp[N][N][L][3];
int main(){
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
cin >> n >> l;
for(int i = 0; i < n; ++i)
cin >> a[i];
sort(a, a+n);
a[n] = L;
dp[0][0][0][0] = 1;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
for(int k = 0; k <= l; ++k){
int dif;
// e = 0
dif = 2*j*(a[i]-a[i-1]);
if(dif <= k){
dp[i][j][k][0] = (dp[i][j][k][0] + dp[i-1][j-1][k - dif][0]*j)%mod;
dp[i][j][k][0] = (dp[i][j][k][0] + dp[i-1][j][k - dif][0]*2*j)%mod;
dp[i][j][k][0] = (dp[i][j][k][0] + dp[i-1][j+1][k - dif][0]*j)%mod;
}
// e = 1
dif = (2*j - 1)*(a[i] - a[i-1]);
if(dif <= k){
dp[i][j][k][1] = (dp[i][j][k][1] + dp[i-1][j-1][k - dif][0]*2)%mod;
dp[i][j][k][1] = (dp[i][j][k][1] + dp[i-1][j][k - dif][0]*2)%mod;
dp[i][j][k][1] = (dp[i][j][k][1] + dp[i-1][j-1][k - dif][1]*(j-1))%mod;
dp[i][j][k][1] = (dp[i][j][k][1] + dp[i-1][j][k - dif][1]*(2*j-1))%mod;
dp[i][j][k][1] = (dp[i][j][k][1] + dp[i-1][j+1][k - dif][1]*j)%mod;
}
// e = 2
dif = (2*j - 2)*(a[i] - a[i-1]);
if(dif <= k){
dp[i][j][k][2] = (dp[i][j][k][2] + dp[i-1][j-1][k - dif][1])%mod;
dp[i][j][k][2] = (dp[i][j][k][2] + dp[i-1][j][k - dif][1])%mod;
dp[i][j][k][2] = (dp[i][j][k][2] + dp[i-1][j-1][k - dif][2]*(j-2))%mod;
dp[i][j][k][2] = (dp[i][j][k][2] + dp[i-1][j][k - dif][2]*(2*j-2))%mod;
dp[i][j][k][2] = (dp[i][j][k][2] + dp[i-1][j+1][k - dif][2]*j)%mod;
}
}
}
}
ll ans = 0;
for(int i = 0; i <= l; ++i)
ans = (ans + dp[n][1][i][2])%mod;
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1132 KB |
Output is correct |
2 |
Correct |
1 ms |
1132 KB |
Output is correct |
3 |
Correct |
1 ms |
1260 KB |
Output is correct |
4 |
Correct |
1 ms |
1152 KB |
Output is correct |
5 |
Correct |
1 ms |
1132 KB |
Output is correct |
6 |
Correct |
2 ms |
1260 KB |
Output is correct |
7 |
Correct |
1 ms |
876 KB |
Output is correct |
8 |
Correct |
2 ms |
1260 KB |
Output is correct |
9 |
Correct |
2 ms |
1388 KB |
Output is correct |
10 |
Correct |
1 ms |
1132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |