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 int long long
int A[200005] ,P[200005];
int n,a,b;
int dp[105][105][105];
int calc(int i, int k, int prev){
if(i == n && !k)return P[i] - P[prev];
else if(i == n)return 1e18;
else if(dp[i][k][prev])return dp[i][k][prev];
else if(k)return dp[i][k][prev] = min((calc(i+1, k-1, i) | (P[i] - P[prev])), calc(i+1, k, prev));
else return dp[i][k][prev] = calc(i+1, k, prev);
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
cin >> n >> a >> b;
for(int i=1;i<=n;i++)cin >> A[i], P[i] = P[i-1] + A[i];
int ans = 1e18;
for(int i=a;i<=b;i++)ans = min(ans, calc(1, i-1, 0));
cout << ans;
}
Compilation message (stderr)
sculpture.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | 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... |