#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105;
const int M=1005;
const int mod=1e9+7;
struct mint{
int x;
mint(ll x=0ll):x(x%mod){}
void upd(){
if(x>=mod)x-=mod;
if(x<0)x+=mod;
}
mint& operator+=(mint rhs){return x+=rhs.x,upd(),*this;}
mint& operator-=(mint rhs){return x-=rhs.x,upd(),*this;}
mint& operator*=(mint rhs){return x=(1ll*x*rhs.x)%mod,*this;}
friend mint operator+(mint lhs,mint rhs){return lhs+=rhs;};
friend mint operator-(mint lhs,mint rhs){return lhs-=rhs;};
friend mint operator*(mint lhs,mint rhs){return lhs*=rhs;};
};
int n,l;
int a[N];
mint dp[N][N][M][4];
mint ans;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> l;
for(int i=1;i<=n;i++)cin >> a[i];
if(n==1)cout << 1,exit(0);
sort(a+1,a+n+1);
dp[1][1][0][0]=1;
dp[1][1][0][1]=2;
for(int i=2;i<=n;i++){
for(int j=1;j<i;j++){
for(int k=0;k<=l;k++){
for(int e=0;e<3;e++){
int res=k+(a[i]-a[i-1])*(2*j-e);
if(res>l)continue;
dp[i][j-1][res][e]+=dp[i-1][j][k][e]*(j-1);
dp[i][j][res][e]+=dp[i-1][j][k][e]*(2*j-e);
dp[i][j+1][res][e]+=dp[i-1][j][k][e]*(j+1-e);
dp[i][j][res][e+1]+=dp[i-1][j][k][e]*(2-e);
dp[i][j+1][res][e+1]+=dp[i-1][j][k][e]*(2-e);
}
}
}
}
for(int i=0;i<=l;i++)ans+=dp[n][1][i][2];
cout << ans.x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
173708 KB |
Output is correct |
2 |
Correct |
69 ms |
173692 KB |
Output is correct |
3 |
Correct |
68 ms |
173700 KB |
Output is correct |
4 |
Correct |
67 ms |
173752 KB |
Output is correct |
5 |
Correct |
68 ms |
173668 KB |
Output is correct |
6 |
Correct |
76 ms |
173676 KB |
Output is correct |
7 |
Correct |
69 ms |
173728 KB |
Output is correct |
8 |
Correct |
76 ms |
173644 KB |
Output is correct |
9 |
Correct |
71 ms |
173652 KB |
Output is correct |
10 |
Correct |
73 ms |
173652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
173656 KB |
Output is correct |
2 |
Correct |
69 ms |
173648 KB |
Output is correct |
3 |
Correct |
68 ms |
173684 KB |
Output is correct |
4 |
Correct |
75 ms |
173692 KB |
Output is correct |
5 |
Correct |
68 ms |
173764 KB |
Output is correct |
6 |
Correct |
68 ms |
173644 KB |
Output is correct |
7 |
Correct |
69 ms |
173700 KB |
Output is correct |
8 |
Correct |
80 ms |
173756 KB |
Output is correct |
9 |
Correct |
68 ms |
173752 KB |
Output is correct |
10 |
Correct |
68 ms |
173664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
173708 KB |
Output is correct |
2 |
Correct |
69 ms |
173692 KB |
Output is correct |
3 |
Correct |
68 ms |
173700 KB |
Output is correct |
4 |
Correct |
67 ms |
173752 KB |
Output is correct |
5 |
Correct |
68 ms |
173668 KB |
Output is correct |
6 |
Correct |
76 ms |
173676 KB |
Output is correct |
7 |
Correct |
69 ms |
173728 KB |
Output is correct |
8 |
Correct |
76 ms |
173644 KB |
Output is correct |
9 |
Correct |
71 ms |
173652 KB |
Output is correct |
10 |
Correct |
73 ms |
173652 KB |
Output is correct |
11 |
Correct |
67 ms |
173656 KB |
Output is correct |
12 |
Correct |
69 ms |
173648 KB |
Output is correct |
13 |
Correct |
68 ms |
173684 KB |
Output is correct |
14 |
Correct |
75 ms |
173692 KB |
Output is correct |
15 |
Correct |
68 ms |
173764 KB |
Output is correct |
16 |
Correct |
68 ms |
173644 KB |
Output is correct |
17 |
Correct |
69 ms |
173700 KB |
Output is correct |
18 |
Correct |
80 ms |
173756 KB |
Output is correct |
19 |
Correct |
68 ms |
173752 KB |
Output is correct |
20 |
Correct |
68 ms |
173664 KB |
Output is correct |
21 |
Correct |
72 ms |
173756 KB |
Output is correct |
22 |
Correct |
177 ms |
173724 KB |
Output is correct |
23 |
Correct |
174 ms |
173652 KB |
Output is correct |
24 |
Correct |
171 ms |
173712 KB |
Output is correct |
25 |
Correct |
183 ms |
173764 KB |
Output is correct |
26 |
Correct |
163 ms |
173764 KB |
Output is correct |
27 |
Correct |
108 ms |
173676 KB |
Output is correct |
28 |
Correct |
122 ms |
173644 KB |
Output is correct |
29 |
Correct |
174 ms |
173772 KB |
Output is correct |
30 |
Correct |
179 ms |
173696 KB |
Output is correct |