이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
int n,L,dp[105][105][2][2][1001],a[105],mod=1e9+7;
void add(int &x,LL y) {
y%=mod;
x+=y;
if(x>=mod)
x-=mod;
}
int f(int x,int cnt,int l,int r,int sum) {
if(x>0)
sum+=(cnt*2+l+r)*(a[x]-a[x-1]);
if(sum>L||cnt<0)
return 0;
if(x==n-1)
return (cnt==0);
int &ret=dp[x][cnt][l][r][sum];
if(ret!=-1)
return ret;
ret=0;
add(ret,f(x+1,cnt,1,r,sum));
add(ret,1LL*f(x+1,cnt-1,1,r,sum)*cnt);
add(ret,f(x+1,cnt,l,1,sum));
add(ret,1LL*f(x+1,cnt-1,l,1,sum)*cnt);
add(ret,f(x+1,cnt+1,l,r,sum));
add(ret,1LL*f(x+1,cnt,l,r,sum)*cnt*2);
add(ret,1LL*f(x+1,cnt-1,l,r,sum)*cnt*(cnt-1));
return ret;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
memset(dp,-1,sizeof dp);
cin>>n>>L;
for(int i=0;i<n;++i)
cin>>a[i];
sort(a,a+n);
cout<<f(0,0,0,0,0)<< endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |