#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 << 40) - 1;
for (ll bit = 39; bit >= 0; bit--) {
c -= (1ll << bit);
if (not ok(c)) c += (1 << bit);
}
cout << c << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
16044 KB |
Output is correct |
2 |
Correct |
72 ms |
16036 KB |
Output is correct |
3 |
Correct |
72 ms |
16040 KB |
Output is correct |
4 |
Correct |
72 ms |
15956 KB |
Output is correct |
5 |
Correct |
83 ms |
16032 KB |
Output is correct |
6 |
Correct |
77 ms |
16036 KB |
Output is correct |
7 |
Correct |
72 ms |
15956 KB |
Output is correct |
8 |
Correct |
70 ms |
16036 KB |
Output is correct |
9 |
Correct |
71 ms |
16040 KB |
Output is correct |
10 |
Correct |
82 ms |
16036 KB |
Output is correct |
11 |
Correct |
84 ms |
16048 KB |
Output is correct |
12 |
Correct |
70 ms |
16076 KB |
Output is correct |
13 |
Correct |
71 ms |
15956 KB |
Output is correct |
14 |
Correct |
73 ms |
16032 KB |
Output is correct |
15 |
Incorrect |
95 ms |
16036 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
15956 KB |
Output is correct |
2 |
Correct |
74 ms |
15940 KB |
Output is correct |
3 |
Correct |
72 ms |
16044 KB |
Output is correct |
4 |
Correct |
82 ms |
16032 KB |
Output is correct |
5 |
Correct |
76 ms |
16040 KB |
Output is correct |
6 |
Correct |
77 ms |
16036 KB |
Output is correct |
7 |
Correct |
72 ms |
15956 KB |
Output is correct |
8 |
Correct |
74 ms |
16032 KB |
Output is correct |
9 |
Correct |
80 ms |
16032 KB |
Output is correct |
10 |
Correct |
83 ms |
16040 KB |
Output is correct |
11 |
Correct |
76 ms |
16040 KB |
Output is correct |
12 |
Correct |
77 ms |
15956 KB |
Output is correct |
13 |
Correct |
78 ms |
15956 KB |
Output is correct |
14 |
Correct |
77 ms |
15940 KB |
Output is correct |
15 |
Incorrect |
76 ms |
16036 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
15956 KB |
Output is correct |
2 |
Correct |
73 ms |
16056 KB |
Output is correct |
3 |
Correct |
72 ms |
15952 KB |
Output is correct |
4 |
Correct |
74 ms |
16036 KB |
Output is correct |
5 |
Correct |
75 ms |
16040 KB |
Output is correct |
6 |
Correct |
72 ms |
15956 KB |
Output is correct |
7 |
Correct |
74 ms |
16076 KB |
Output is correct |
8 |
Correct |
73 ms |
16076 KB |
Output is correct |
9 |
Correct |
79 ms |
16040 KB |
Output is correct |
10 |
Correct |
82 ms |
15956 KB |
Output is correct |
11 |
Correct |
72 ms |
16032 KB |
Output is correct |
12 |
Correct |
77 ms |
16160 KB |
Output is correct |
13 |
Correct |
74 ms |
16040 KB |
Output is correct |
14 |
Correct |
80 ms |
15956 KB |
Output is correct |
15 |
Correct |
71 ms |
16036 KB |
Output is correct |
16 |
Correct |
73 ms |
16032 KB |
Output is correct |
17 |
Correct |
81 ms |
16036 KB |
Output is correct |
18 |
Correct |
81 ms |
15956 KB |
Output is correct |
19 |
Correct |
81 ms |
16036 KB |
Output is correct |
20 |
Correct |
73 ms |
16032 KB |
Output is correct |
21 |
Correct |
75 ms |
16036 KB |
Output is correct |
22 |
Correct |
75 ms |
15956 KB |
Output is correct |
23 |
Correct |
77 ms |
15956 KB |
Output is correct |
24 |
Correct |
82 ms |
16036 KB |
Output is correct |
25 |
Correct |
73 ms |
16020 KB |
Output is correct |
26 |
Correct |
74 ms |
16048 KB |
Output is correct |
27 |
Correct |
75 ms |
16036 KB |
Output is correct |
28 |
Correct |
79 ms |
16036 KB |
Output is correct |
29 |
Correct |
86 ms |
16036 KB |
Output is correct |
30 |
Correct |
80 ms |
15956 KB |
Output is correct |
31 |
Correct |
77 ms |
16044 KB |
Output is correct |
32 |
Correct |
82 ms |
15956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
16040 KB |
Output is correct |
2 |
Correct |
76 ms |
15956 KB |
Output is correct |
3 |
Correct |
76 ms |
16004 KB |
Output is correct |
4 |
Correct |
73 ms |
15956 KB |
Output is correct |
5 |
Correct |
72 ms |
16032 KB |
Output is correct |
6 |
Correct |
73 ms |
16036 KB |
Output is correct |
7 |
Correct |
74 ms |
15956 KB |
Output is correct |
8 |
Correct |
82 ms |
16036 KB |
Output is correct |
9 |
Correct |
75 ms |
16036 KB |
Output is correct |
10 |
Correct |
72 ms |
16032 KB |
Output is correct |
11 |
Correct |
71 ms |
15976 KB |
Output is correct |
12 |
Correct |
85 ms |
15956 KB |
Output is correct |
13 |
Correct |
77 ms |
16036 KB |
Output is correct |
14 |
Correct |
73 ms |
16032 KB |
Output is correct |
15 |
Incorrect |
73 ms |
16040 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
16040 KB |
Output is correct |
2 |
Correct |
83 ms |
15956 KB |
Output is correct |
3 |
Correct |
73 ms |
16032 KB |
Output is correct |
4 |
Correct |
73 ms |
15956 KB |
Output is correct |
5 |
Correct |
75 ms |
16044 KB |
Output is correct |
6 |
Correct |
74 ms |
15956 KB |
Output is correct |
7 |
Correct |
73 ms |
15972 KB |
Output is correct |
8 |
Correct |
77 ms |
15956 KB |
Output is correct |
9 |
Correct |
71 ms |
15956 KB |
Output is correct |
10 |
Correct |
72 ms |
16040 KB |
Output is correct |
11 |
Correct |
74 ms |
16036 KB |
Output is correct |
12 |
Correct |
75 ms |
16032 KB |
Output is correct |
13 |
Correct |
74 ms |
16056 KB |
Output is correct |
14 |
Correct |
79 ms |
16032 KB |
Output is correct |
15 |
Correct |
73 ms |
16084 KB |
Output is correct |
16 |
Correct |
75 ms |
16032 KB |
Output is correct |
17 |
Incorrect |
72 ms |
15956 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |