This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 6e5 + 10;
const int MOD = 1e9 + 7;
void solve(int tc){
int N; cin >> N;
int A, B; cin >> A >> B;
int Y[N+1]; for(int i=1; i<=N; i++) cin >> Y[i];
int dp[N+1][N+1];
int ps[N+1];
ps[0]=0;
for(int i=1; i<=N; i++){
ps[i]=ps[i-1]+Y[i];
dp[1][i]=ps[i];
}
for(int i=2; i<=N; i++){
for(int j=i; j<=N; j++){
dp[i][j]=1e18;
for(int k=i-1; k<j; k++){
dp[i][j]=min(dp[i][j],dp[i-1][k]|(ps[j]-ps[k]));
}
}
}
int ans=1e18;
for(int i=A; i<=B; i++) ans = min(ans, dp[i][N]);
cout << ans << endl;
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; // cin >> t;
int cnt = 0;
while(t--) solve(++cnt);
}
# | 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... |