#include <bits/stdc++.h>
using namespace std;
#define int long long
int DP[2001][2001];
int arr[2001];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,a,b;
cin >> n >> a >> b;
for(int i=1;i<=n;i++)cin>>arr[i];
for(int i=1;i<=n;i++)DP[i][0]=INT64_MAX;
for(int j=1;j<=b;j++){
for(int i=j;i<=n;i++){
int sum = arr[i];
DP[i][j] = INT64_MAX;
for(int x=i-1;x>=j-1;x--){
DP[i][j]=min(DP[i][j],DP[x][j-1]|sum);
sum+=arr[x];
}
}
}
int ans = INT64_MAX;
for(int i=a;i<=b;i++)ans=min(ans,DP[n][i]);
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
436 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 |
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 |
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 |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |