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>
#define ll long long
using namespace std;
ll n;
ll arr[2010];
ll memo[100][100][410];
ll a, b;
const ll inf = 1e18;
ll rek( int p, int k, int o ) {
if(p==n) {
if(k>=a&&k<=b) return o;
return inf;
}
if(memo[p][k][o]) return memo[p][k][o];
ll sum = 0, ans = inf;
for(int i = p; i < n; i++) {
sum += arr[i];
ans = min(rek(i+1, k+1, o|sum), ans);
}
memo[p][k][o] = ans;
return ans;
}
int main( void ) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> a >> b;
for(int i = 0; i < n; i++) cin >> arr[i];
cout << rek(0, 0, 0);
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... |