#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 2100;
ll n, a, b;
ll arr[maxn];
ll dp[110][110];
int main() {
cin>>n>>a>>b;
for(int i=1;i<=n;i++) {
cin>>arr[i];
}
if(n <= 100) {
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
dp[i][j] = (1LL<<50)-1;
dp[0][0] = 0LL;
for(int p=1;p<=n;p++) {
for(int i=1;i<=n;i++) {
ll sum = 0LL;
for(int l=i;l>=1;l--) {
sum += arr[l];
dp[p][i] = min(dp[p][i], dp[p-1][l-1] | sum);
}
}
}
ll result = LLONG_MAX;
for(int i=1;i<=n;i++) {
if(i >= a && i <= b) result = min(result, dp[i][n]);
}
cout<<result<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |