#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
using namespace std;
const ll N=1e6,mod=1e9 +7;
ll a,b,c,d,n,l;
ll t[N];
ll dp[(1<<14)][15][110];
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
ll T=1;
// cin>>T;
while(T--){
cin>>n>>l;
for(ll i=0;i<n;i++){
cin>>t[i];
}
memset(dp,0,sizeof(dp));
for(ll i=0;i<n;i++){
dp[(1<<i)][i][0]=1;
}
for(ll i=0;i<(1<<n);i++){
for(ll j=0;j<n;j++){
if(i&(1<<j)){
for(ll k=0;k<n;k++){
if(!(i & (1<<k))){
for(ll m=0;m<=l;m++){
if(m+abs(t[j]-t[k])<=l)
dp[i+(1<<k)][k][m+abs(t[j]-t[k])]+=dp[i][j][m];
}
}
}
}
}
}
ll res=0;
for(ll i=0;i<n;i++){
for(ll j=0;j<=l;j++){
res+=dp[(1<<n)-1][i][j];
}
}
cout<<res<<"\n";
}
return 0;
}
/*
4 10
3 6 2 9
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |