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;
using ll = long long;
int N, A, B;
ll sum[2005], dp[2005][2005];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin>>N>>A>>B;
for(int i=1;i<=N;i++) cin>>sum[i], sum[i] += sum[i-1];
for(int i=1;i<=N;i++) for(int j=0;j<B;j++) dp[i][j] = 1e18;
for(int i=1;i<=N;i++) dp[i][0] = sum[i];
for(int j=1;j<B;j++) {
for(int i=1;i<=N;i++) {
for(int k=j+1;k<i;k++) {
dp[i][j] = min(dp[i][j], dp[k][j-1]|(sum[i]-sum[k]));
}
}
}
ll ans = 1e18;
for(int j=A-1;j<B;j++) ans = min(ans, dp[N][j]);
cout<<ans;
}
# | 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... |