이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,l,ans,mod=1e9+7;
int arr[55];
int dp[55][10005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> l;
for(int i=1;i<=n;i++){
cin >> arr[i];
}
sort(arr+1,arr+n+1);
dp[1][1] = 1;
for(int i=2;i<=n;i++){
for(int j=0;j<=l;j++){
if(j>=arr[i]){
dp[i][j] += dp[i-1][j-arr[i]]*2LL;
dp[i][j] %= mod;
}
if(j>=arr[i]*2LL-1LL){
dp[i][j] += dp[i-1][j-arr[i]*2LL+1LL]*(i-2LL);
dp[i][j] %= mod;
}
}
}
for(int j=0;j<=l;j++){
ans += dp[n][j]*(l-j+1LL);
ans %= mod;
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |