#include <iostream>
#include <cstring>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int N = 2000;
int n, a, b, dp[N + 5][N + 5];
ll x[N + 5];
bool isSubmask(ll sup, ll sub) {
return (sup | sub) == sup;
}
int brutus(int l, int r, ll c) {
if (r == n) return (isSubmask(c, x[r] - x[l - 1]) ? 0 : INF);
if (dp[l][r] != -1) return dp[l][r];
int &ret = dp[l][r];
ret = brutus(l, r + 1, c);
if (isSubmask(c, x[r] - x[l - 1])) ret = min(ret, 1 + brutus(r + 1, r + 1, c));
// cout << l << ' ' << r << ' ' << ret << endl;
return ret;
}
bool ok(ll target) {
memset(dp, -1, sizeof dp);
return 1 + brutus(1, 1, target) <= b;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> a >> b;
x[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> x[i];
x[i] += x[i - 1];
}
ll c = (1ll << 42) - 1;
for (ll bit = 41; bit >= 0; bit--) {
c -= (1ll << bit);
if (not ok(c)) c += (1 << bit);
}
cout << c << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
16040 KB |
Output is correct |
2 |
Correct |
74 ms |
15956 KB |
Output is correct |
3 |
Correct |
74 ms |
15956 KB |
Output is correct |
4 |
Correct |
74 ms |
15956 KB |
Output is correct |
5 |
Correct |
72 ms |
15956 KB |
Output is correct |
6 |
Correct |
79 ms |
16036 KB |
Output is correct |
7 |
Correct |
73 ms |
16032 KB |
Output is correct |
8 |
Correct |
75 ms |
16160 KB |
Output is correct |
9 |
Correct |
78 ms |
16032 KB |
Output is correct |
10 |
Correct |
73 ms |
16040 KB |
Output is correct |
11 |
Correct |
77 ms |
15956 KB |
Output is correct |
12 |
Correct |
77 ms |
15956 KB |
Output is correct |
13 |
Correct |
72 ms |
16048 KB |
Output is correct |
14 |
Correct |
75 ms |
15956 KB |
Output is correct |
15 |
Incorrect |
82 ms |
16032 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
15956 KB |
Output is correct |
2 |
Correct |
77 ms |
15956 KB |
Output is correct |
3 |
Correct |
74 ms |
15956 KB |
Output is correct |
4 |
Correct |
73 ms |
16040 KB |
Output is correct |
5 |
Correct |
72 ms |
15956 KB |
Output is correct |
6 |
Correct |
83 ms |
16032 KB |
Output is correct |
7 |
Correct |
71 ms |
15956 KB |
Output is correct |
8 |
Correct |
72 ms |
15956 KB |
Output is correct |
9 |
Correct |
71 ms |
16036 KB |
Output is correct |
10 |
Correct |
73 ms |
15956 KB |
Output is correct |
11 |
Correct |
75 ms |
15956 KB |
Output is correct |
12 |
Correct |
76 ms |
16032 KB |
Output is correct |
13 |
Correct |
82 ms |
15956 KB |
Output is correct |
14 |
Correct |
79 ms |
15956 KB |
Output is correct |
15 |
Incorrect |
77 ms |
16032 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
16040 KB |
Output is correct |
2 |
Correct |
85 ms |
16032 KB |
Output is correct |
3 |
Correct |
78 ms |
16036 KB |
Output is correct |
4 |
Correct |
75 ms |
16036 KB |
Output is correct |
5 |
Correct |
72 ms |
16048 KB |
Output is correct |
6 |
Correct |
74 ms |
16076 KB |
Output is correct |
7 |
Correct |
77 ms |
15956 KB |
Output is correct |
8 |
Correct |
73 ms |
15956 KB |
Output is correct |
9 |
Correct |
71 ms |
16032 KB |
Output is correct |
10 |
Correct |
73 ms |
16036 KB |
Output is correct |
11 |
Correct |
73 ms |
15956 KB |
Output is correct |
12 |
Correct |
75 ms |
15956 KB |
Output is correct |
13 |
Correct |
75 ms |
16032 KB |
Output is correct |
14 |
Correct |
83 ms |
15956 KB |
Output is correct |
15 |
Correct |
77 ms |
16032 KB |
Output is correct |
16 |
Correct |
77 ms |
16032 KB |
Output is correct |
17 |
Correct |
74 ms |
16032 KB |
Output is correct |
18 |
Correct |
73 ms |
16044 KB |
Output is correct |
19 |
Correct |
73 ms |
16028 KB |
Output is correct |
20 |
Correct |
71 ms |
16040 KB |
Output is correct |
21 |
Correct |
76 ms |
16036 KB |
Output is correct |
22 |
Correct |
76 ms |
16036 KB |
Output is correct |
23 |
Correct |
77 ms |
15940 KB |
Output is correct |
24 |
Correct |
78 ms |
16060 KB |
Output is correct |
25 |
Correct |
74 ms |
16036 KB |
Output is correct |
26 |
Correct |
76 ms |
16032 KB |
Output is correct |
27 |
Correct |
76 ms |
16040 KB |
Output is correct |
28 |
Correct |
75 ms |
15956 KB |
Output is correct |
29 |
Correct |
76 ms |
16040 KB |
Output is correct |
30 |
Correct |
75 ms |
15956 KB |
Output is correct |
31 |
Correct |
74 ms |
15956 KB |
Output is correct |
32 |
Correct |
76 ms |
16036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
16040 KB |
Output is correct |
2 |
Correct |
72 ms |
16036 KB |
Output is correct |
3 |
Correct |
79 ms |
16040 KB |
Output is correct |
4 |
Correct |
77 ms |
16052 KB |
Output is correct |
5 |
Correct |
73 ms |
16036 KB |
Output is correct |
6 |
Correct |
73 ms |
15996 KB |
Output is correct |
7 |
Correct |
73 ms |
15956 KB |
Output is correct |
8 |
Correct |
72 ms |
15956 KB |
Output is correct |
9 |
Correct |
75 ms |
15956 KB |
Output is correct |
10 |
Correct |
71 ms |
16036 KB |
Output is correct |
11 |
Correct |
74 ms |
16040 KB |
Output is correct |
12 |
Correct |
72 ms |
15956 KB |
Output is correct |
13 |
Correct |
73 ms |
16036 KB |
Output is correct |
14 |
Correct |
74 ms |
15996 KB |
Output is correct |
15 |
Incorrect |
74 ms |
16036 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
16040 KB |
Output is correct |
2 |
Correct |
75 ms |
16036 KB |
Output is correct |
3 |
Correct |
71 ms |
16036 KB |
Output is correct |
4 |
Correct |
73 ms |
16036 KB |
Output is correct |
5 |
Correct |
74 ms |
16036 KB |
Output is correct |
6 |
Correct |
70 ms |
15956 KB |
Output is correct |
7 |
Correct |
80 ms |
15956 KB |
Output is correct |
8 |
Correct |
76 ms |
15956 KB |
Output is correct |
9 |
Correct |
74 ms |
16032 KB |
Output is correct |
10 |
Correct |
71 ms |
16032 KB |
Output is correct |
11 |
Correct |
72 ms |
15956 KB |
Output is correct |
12 |
Correct |
76 ms |
15956 KB |
Output is correct |
13 |
Correct |
75 ms |
15956 KB |
Output is correct |
14 |
Correct |
72 ms |
15956 KB |
Output is correct |
15 |
Correct |
72 ms |
15956 KB |
Output is correct |
16 |
Correct |
71 ms |
15984 KB |
Output is correct |
17 |
Incorrect |
77 ms |
16052 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |