#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=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 |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |