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;
#define ll long long
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 2e3;
int N, A, B;
ll a[MAXN], DP[MAXN+1][MAXN+1];
ll f(int pos, int gruppo){
if(pos == N){
if(gruppo < A || gruppo > B)
return LLONG_MAX;
return 0;
}
if(gruppo > B || gruppo+N-pos < A) return LLONG_MAX;
if(DP[pos][gruppo] != -1) return DP[pos][gruppo];
ll sum = 0, best = LLONG_MAX, res;
for(int i = pos; i < N; i++){
sum += a[i];
res = f(i+1, gruppo+1);
best = min(best, (sum|res));
}
return DP[pos][gruppo] = best;
}
main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> A >> B;
for(int i = 0; i < N; i++) cin >> a[i];
memset(DP, -1, sizeof(DP));
cout << f(0, 0);
}
Compilation message (stderr)
sculpture.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# | 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... |