# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43777 | Extazy | Bali Sculptures (APIO15_sculpture) | C++14 | 6 ms | 2120 KiB |
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;
const int N = 2007;
int n,a,b;
long long ans;
bool used[N][N];
long long state[N][N];
long long arr[N];
long long get_sum(int l, int r) {
return arr[r]-arr[l-1];
}
long long recurse(int pos, int groups) {
if(groups<0) return 1000000000000000000;
if(pos>n) {
if(groups==0) return 0;
return 1;
}
if(used[pos][groups]) return state[pos][groups];
int i;
long long ans=1000000000000000000;
for(i=pos;i<=n;i++) {
ans=min(ans,recurse(i+1,groups-1)|get_sum(pos,i));
}
used[pos][groups]=true;
return state[pos][groups]=ans;
}
int main() {
int i;
scanf("%d %d %d", &n, &a, &b);
for(i=1;i<=n;i++) {
scanf("%lld", &arr[i]);
arr[i]+=arr[i-1];
}
ans=recurse(1,a);
while(++a<=b) ans=min(ans,recurse(1,a));
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | 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... |