This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> ii;
#define f(i,a,b) for(int i = a; i < b; i++)
#define fa(i,a,b) for(int i = a; i >= b; i--)
const int N = 2005;
const ll inf = 1e18 + 10;
int n, a, b, x[55];
bool dp[55][21][505];
int main(){
cin >> n >> a >> b;
f(i,1,n+1) cin >> x[i];
dp[0][0][0] = 1;
f(i,1,n+1){
int s = 0;
fa(j,i,1){
s += x[j];
fa(g,min(20,i),1){
f(k,0,501) {
if(dp[j-1][g-1][k])
dp[i][g][(k|s)] = 1;
}
}
}
}
int ans = 10000;
f(i,a,b+1){
f(j,0,505) if(dp[n][i][j]) ans = min(ans, j);
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |