#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
// #pragma GCC optimize("Ofast")
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 0, n + 1)
#define SZ(x) (int)(x).size()
#define pb push_back
#define pf push_front
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
#define ckmin(a, b) a = min(a, b)
#define ckmax(a, b) a = max(a, b)
#define int long long
const int INF = 1e18;
const int maxn = 1000 + 5;
const int N = 1e9 + 7;
ll dp[105][105][1005][3];
signed main(void){
fastio;
int n, L;
cin>>n>>L;
vector<int> a(n);
for(int i = 0; i < n; i++) cin>>a[i];
sort(a.begin(), a.end());
a.pb(a[n - 1]);
dp[0][0][0][0] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j <= i; j++){
for(int k = 0; k <= L; k++){
for(int l = 0; l <= 2; l++){
dp[i][j][k][l] %= N;
if(k + (2 * j - 2 - l) * (a[i + 1] - a[i]) > L) continue;
if(j) dp[i + 1][j][k + (2 * j - l) * (a[i + 1] - a[i])][l] += dp[i][j][k][l] * (2 * j - l);
dp[i + 1][j + 1][k + (2 * j + 2 - l) * (a[i + 1] - a[i])][l] += dp[i][j][k][l] * (j + 1 - l);
if(j > 1) dp[i + 1][j - 1][k + (2 * j - 2 - l) * (a[i + 1] - a[i])][l] += dp[i][j][k][l] * (j - 1);
if(l != 2){
dp[i + 1][j][k + (2 * j - (l + 1)) * (a[i + 1] - a[i])][l + 1] += dp[i][j][k][l] * (2 - l);//..............
dp[i + 1][j + 1][k + (2 * j + 2 - (l + 1)) * (a[i + 1] - a[i])][l + 1] += dp[i][j][k][l] * (2 - l);
}
}
}
}
}
ll ans = 0;
for(int i = 0; i <= L; i++) (ans += dp[n - 1][2][i][2]) %= N;
for(int i = 0; i <= L; i++) (ans += dp[n - 1][1][i][1]) %= N;
// for(int i = 0; i <= L; i++) (ans += dp[n][1][i][2]) %= N;
cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
29020 KB |
Output is correct |
2 |
Correct |
4 ms |
33116 KB |
Output is correct |
3 |
Correct |
4 ms |
33296 KB |
Output is correct |
4 |
Correct |
4 ms |
33280 KB |
Output is correct |
5 |
Correct |
4 ms |
33284 KB |
Output is correct |
6 |
Correct |
4 ms |
33116 KB |
Output is correct |
7 |
Correct |
4 ms |
33228 KB |
Output is correct |
8 |
Correct |
4 ms |
33116 KB |
Output is correct |
9 |
Correct |
4 ms |
33116 KB |
Output is correct |
10 |
Correct |
4 ms |
33116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |