#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9, mod = 1e9+7;
ll f[102][102][1002][3];
void solve(){
int n, s;
cin >> n >> s;
vector<ll> h(n+1);
for(int i = 1; i <= n; i++){
cin >> h[i];
}
sort(h.begin()+1, h.end());
f[0][0][0][0] = 1;
h.push_back(10000);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= i; j++){
for(int k = 0; k <= s; k++){
for(int m = 0; m <= 2; m++){
ll cost = (j*2-m)*(h[i+1]-h[i]);
if(k-cost < 0 || i+j+1-m > n) continue;
f[i][j][k][m] += f[i-1][j-1][k-cost][m];
if(m) f[i][j][k][m] += f[i-1][j-1][k-cost][m-1] * (3-m);
f[i][j][k][m] += f[i-1][j][k-cost][m] * (j*2-m);
if(m == 1){
f[i][j][k][m] += f[i-1][j][k-cost][m-1] * (j*2);
}else if(m == 2){
if(i == n){
f[i][j][k][m] += f[i-1][j][k-cost][m-1];
}else if(j > 1){
f[i][j][k][m] += f[i-1][j][k-cost][m-1] * (j-1);
}
}
if(m == 0){
f[i][j][k][m] += f[i-1][j+1][k-cost][m] * (j*(j+1)%mod);
}else if(m == 1){
f[i][j][k][m] += f[i-1][j+1][k-cost][m] * (j*j);
}else if(m == 2){
if(i == n){
f[i][j][k][m] += f[i-1][j+1][k-cost][m];
}else{
f[i][j][k][m] += f[i-1][j+1][k-cost][m] * (j*(j-1)%mod);
}
}
f[i][j][k][m] %= mod;
}
}
}
}
ll ans = 0;
for(int k = 0; k <= s; k++){
ans += f[n][1][k][2];
}
ans %= mod;
cout << ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |