#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[2005][2005];
ll pref[2005];
int main(){
int n,l,u;
cin >> n >> l >> u;
vector<int> a(n);
for(auto &x: a){
cin >> x;
}
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
dp[i][j] = (ll) 1e18;
}
}
dp[0][0] = 0;
for(int i = 0; i < n; i++){
pref[i+1] = pref[i] + a[i];
}
for(int i = 1; i <= n; i++){
for(int k = 1; k <= n; k++){
for(int j = 0; j < i; j++){
dp[i][k] = min(dp[i][k],dp[j][k-1] | (pref[i] - pref[j]));
}
}
}
ll ans = 1e18;
for(int i = l; i <= u; i++){
ans = min(ans,dp[n][i]);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |