#include <bits/stdc++.h>
#define int long long
using namespace std;
const int NMAX = 2048;
const int INF = 1e18L;
int N, A, B, a[NMAX], dp[NMAX], ans = (1LL << 60) - 1;
void min_self(int &a, int b) {
a = min(a, b);
}
bool check() {
for(int i = 1; i <= N; ++i)
dp[i] = INF;
for(int i = 0; i < N; ++i) {
int sum = 0;
for(int j = i; j < N; ++j) {
sum += a[j];
if((sum | ans) == ans)
min_self(dp[j + 1], dp[i] + 1);
}
}
return dp[N] <= B;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> N >> A >> B;
for(int i = 0; i < N; ++i)
cin >> a[i];
for(int bit = 59; bit >= 0; --bit) {
ans ^= (1LL << bit);
if(!check())
ans |= (1LL << bit);
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |