// 01001100 01001111 01010100 01000001 \\
// \\
// ╦ ╔═╗╔╦╗╔═╗ \\
// ║ ║ ║ ║ ╠═╣ \\
// ╩═╝╚═╝ ╩ ╩ ╩ \\
// \\
// 01001100 01001111 01010100 01000001 \\
#include <bits/stdc++.h>
using namespace std;
#define N 101
#define K 1001
#define nl '\n'
#define ff first
#define ss second
#define add insert
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int M = 1e9 + 7;
int add(int x, int y){
return (x + y) % M;
}
int mul(int x, int y){
return (1ll * x * y) % M;
}
int a[N];
int dp[N][N][K][3];
void solve(){
int n, L, val, ans;
cin >> n >> L;
for(int i = 1; i <= n; i++)
cin >> a[i];
dp[1][1][0][0] = 1;
dp[1][1][0][1] = 2;
dp[1][1][0][2] = 1;
sort(a + 1, a + n + 1);
for(int i = 2; i <= n; i++){
for(int j = 1; j < i; j++){
for(int l = 0; l <= L; l++){
for(int k = 0; k < 3; k++){
val = (a[i] - a[i - 1]) * (2 * j - k) + l;
if(val > L) continue;
dp[i][j - 1][val][k] = add(dp[i][j - 1][val][k], mul(dp[i - 1][j][l][k], j - 1));
dp[i][j][val][k] = add(dp[i][j][val][k], mul(dp[i - 1][j][l][k], 2 * j - k));
dp[i][j + 1][val][k] = add(dp[i][j + 1][val][k], mul(dp[i - 1][j][l][k], j + 1 - k));
if(k > 1) continue;
dp[i][j][val][k + 1] = add(dp[i][j][val][k + 1], mul(dp[i - 1][j][l][k], 2 - k));
dp[i][j + 1][val][k + 1] = add(dp[i][j + 1][val][k + 1], mul(dp[i - 1][j][l][k], 2 - k));
}
}
}
}
for(int i = ans = 0; i <= L; i++)
ans = add(ans, dp[n][1][i][2]);
cout << ans;
}
int terminator(){
L0TA;
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |