#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
const int N = 100 +5;
const int M = 1000 +5;
const int mod = 1e9+7;
typedef pair<int,int> pii;
inline int add(int x, int y)
{
return (x+y>=mod ? x+y-mod : x+y);
}
inline int sub(int x, int y)
{
return (x-y<0 ? x-y+mod : x-y);
}
inline int gun(int x, int y)
{
return ((x*1ll*y)%mod);
}
int n,l;
int a[N];
int dp[N][M][M][3];
int solve(int idx, int comps, int sum , int matha)
{
if(sum > l)
return 0;
if(comps < 0 || comps >n)
return 0;
if(comps == 0 && idx>0)
return 0;
if(matha > 2)
return 0;
if(idx==n)
{
if(comps == 1 && matha == 2)
return 1;
return 0;
}
int &ret = dp[idx][comps][sum][matha];
if(ret!=-1)
return ret;
int prv = (idx-1>=0?a[idx-1] : 0);
int notun = sum + (a[idx]-prv)*(2*comps - matha);
int ans = 0;
//Create
ans = add(ans , gun(comps+1 - matha , solve(idx+1 , comps+1 , notun , matha)));
//merge
ans = add(ans , gun(comps-1, solve(idx+1 , comps-1, notun , matha)) );
//add
ans = add(ans , gun(2*comps-matha , solve(idx+1 , comps , notun , matha)));
//notun matha
ans = add(ans , gun(2-matha, solve(idx+1 , comps+1 , notun , matha+1)));
//mathay lagao
ans = add(ans , gun(2-matha, solve(idx+1 , comps , notun , matha+1)));
return ret = ans;
}
int32_t main()
{
#ifndef APURBA
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#endif
memset(dp,-1,sizeof dp);
cin>>n>>l;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
if(n==1)
{
cout<<"1\n";
return 0;
}
cout<<solve(0,0,0,0)<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
196 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
188 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
196 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |