#include <bits/stdc++.h>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood
#define left not_right
#define y1 what
using namespace std;
const int N = (int) 2e3 + 10;
const int M = (int) 200 + 100;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;
const int nx[4] = {0, 0, -1, 1};
const int ny[4] = {1, -1, 0, 0};
int n, L, R;
ll a[N];
int dp[N];
ll get_sum(int l, int r) {
return a[r] - a[l - 1];
}
void upd(int &x, int y) {
x = min(x, y);
}
bool check(ll x, ll y, int i) {
x |= (1LL << i) - 1;
x = ~x;
if ((x & y) > 0) {
return false;
}
return true;
}
bitset<M> d[M];
bool can(int id, ll val) {
if (n <= 100) {
d[0][0] = 1;
for (int r = 1; r <= n; r++) {
d[r].reset();
for (int l = 1; l <= r; l++) {
if (check(val, get_sum(l, r), id)) {
d[r] |= d[l - 1] << 1;
}
}
}
for (int i = L; i <= R; i++) {
if (d[n][i])
return true;
}
return false;
}
dp[0] = 0;
for (int r = 1; r <= n; r++) {
dp[r] = R + 1;
for (int l = 1; l <= r; l++) {
if (check(val, get_sum(l, r), id))
dp[r] = min(dp[r], dp[l - 1] + 1);
}
}
return dp[n] <= R;
}
int main() {
#define fn "teams"
#ifdef witch
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
//freopen(fn".in", "r", stdin);
//freopen(fn".out", "w", stdout);
#endif
cin >> n >> L >> R;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] += a[i - 1];
}
ll val = 0;
for (int bits = 60; bits >= 0; bits--) {
if (!can(bits, val)) {
val |= (1LL << bits);
}
}
cout << val;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
376 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
408 KB |
Output is correct |
6 |
Correct |
2 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
500 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
2 ms |
564 KB |
Output is correct |
10 |
Correct |
2 ms |
564 KB |
Output is correct |
11 |
Correct |
2 ms |
564 KB |
Output is correct |
12 |
Correct |
2 ms |
564 KB |
Output is correct |
13 |
Correct |
2 ms |
564 KB |
Output is correct |
14 |
Correct |
1 ms |
572 KB |
Output is correct |
15 |
Correct |
2 ms |
620 KB |
Output is correct |
16 |
Correct |
1 ms |
620 KB |
Output is correct |
17 |
Correct |
1 ms |
620 KB |
Output is correct |
18 |
Correct |
2 ms |
620 KB |
Output is correct |
19 |
Correct |
2 ms |
620 KB |
Output is correct |
20 |
Correct |
2 ms |
620 KB |
Output is correct |
21 |
Correct |
2 ms |
620 KB |
Output is correct |
22 |
Correct |
2 ms |
620 KB |
Output is correct |
23 |
Correct |
2 ms |
620 KB |
Output is correct |
24 |
Correct |
2 ms |
620 KB |
Output is correct |
25 |
Correct |
2 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
620 KB |
Output is correct |
27 |
Correct |
2 ms |
620 KB |
Output is correct |
28 |
Correct |
2 ms |
620 KB |
Output is correct |
29 |
Correct |
2 ms |
620 KB |
Output is correct |
30 |
Correct |
2 ms |
620 KB |
Output is correct |
31 |
Correct |
1 ms |
620 KB |
Output is correct |
32 |
Correct |
2 ms |
620 KB |
Output is correct |
33 |
Correct |
2 ms |
620 KB |
Output is correct |
34 |
Correct |
2 ms |
620 KB |
Output is correct |
35 |
Correct |
2 ms |
620 KB |
Output is correct |
36 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
2 ms |
620 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
14 |
Correct |
2 ms |
620 KB |
Output is correct |
15 |
Correct |
2 ms |
620 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
620 KB |
Output is correct |
18 |
Correct |
2 ms |
620 KB |
Output is correct |
19 |
Correct |
2 ms |
620 KB |
Output is correct |
20 |
Correct |
2 ms |
620 KB |
Output is correct |
21 |
Correct |
2 ms |
620 KB |
Output is correct |
22 |
Correct |
2 ms |
620 KB |
Output is correct |
23 |
Correct |
2 ms |
620 KB |
Output is correct |
24 |
Correct |
2 ms |
620 KB |
Output is correct |
25 |
Correct |
2 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
620 KB |
Output is correct |
27 |
Correct |
2 ms |
620 KB |
Output is correct |
28 |
Correct |
3 ms |
620 KB |
Output is correct |
29 |
Correct |
2 ms |
620 KB |
Output is correct |
30 |
Correct |
3 ms |
620 KB |
Output is correct |
31 |
Correct |
3 ms |
620 KB |
Output is correct |
32 |
Correct |
3 ms |
620 KB |
Output is correct |
33 |
Correct |
3 ms |
620 KB |
Output is correct |
34 |
Correct |
3 ms |
620 KB |
Output is correct |
35 |
Correct |
3 ms |
620 KB |
Output is correct |
36 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
620 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
2 ms |
620 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
14 |
Correct |
2 ms |
620 KB |
Output is correct |
15 |
Correct |
2 ms |
620 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
620 KB |
Output is correct |
18 |
Correct |
2 ms |
620 KB |
Output is correct |
19 |
Correct |
2 ms |
620 KB |
Output is correct |
20 |
Correct |
2 ms |
620 KB |
Output is correct |
21 |
Correct |
4 ms |
620 KB |
Output is correct |
22 |
Correct |
3 ms |
620 KB |
Output is correct |
23 |
Correct |
2 ms |
620 KB |
Output is correct |
24 |
Correct |
2 ms |
620 KB |
Output is correct |
25 |
Correct |
4 ms |
620 KB |
Output is correct |
26 |
Correct |
4 ms |
620 KB |
Output is correct |
27 |
Correct |
4 ms |
620 KB |
Output is correct |
28 |
Correct |
5 ms |
620 KB |
Output is correct |
29 |
Correct |
6 ms |
620 KB |
Output is correct |
30 |
Correct |
7 ms |
620 KB |
Output is correct |
31 |
Correct |
5 ms |
620 KB |
Output is correct |
32 |
Correct |
6 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
620 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
1 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
620 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
14 |
Correct |
2 ms |
620 KB |
Output is correct |
15 |
Correct |
1 ms |
620 KB |
Output is correct |
16 |
Correct |
1 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
620 KB |
Output is correct |
18 |
Correct |
1 ms |
620 KB |
Output is correct |
19 |
Correct |
2 ms |
620 KB |
Output is correct |
20 |
Correct |
2 ms |
620 KB |
Output is correct |
21 |
Correct |
2 ms |
620 KB |
Output is correct |
22 |
Correct |
2 ms |
620 KB |
Output is correct |
23 |
Correct |
2 ms |
620 KB |
Output is correct |
24 |
Correct |
2 ms |
620 KB |
Output is correct |
25 |
Correct |
2 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
620 KB |
Output is correct |
27 |
Correct |
2 ms |
620 KB |
Output is correct |
28 |
Correct |
2 ms |
620 KB |
Output is correct |
29 |
Correct |
2 ms |
620 KB |
Output is correct |
30 |
Correct |
2 ms |
620 KB |
Output is correct |
31 |
Correct |
2 ms |
620 KB |
Output is correct |
32 |
Correct |
2 ms |
620 KB |
Output is correct |
33 |
Correct |
2 ms |
620 KB |
Output is correct |
34 |
Correct |
2 ms |
620 KB |
Output is correct |
35 |
Correct |
2 ms |
620 KB |
Output is correct |
36 |
Correct |
2 ms |
620 KB |
Output is correct |
37 |
Correct |
2 ms |
620 KB |
Output is correct |
38 |
Correct |
2 ms |
620 KB |
Output is correct |
39 |
Correct |
2 ms |
620 KB |
Output is correct |
40 |
Correct |
2 ms |
620 KB |
Output is correct |
41 |
Correct |
2 ms |
620 KB |
Output is correct |
42 |
Correct |
2 ms |
620 KB |
Output is correct |
43 |
Correct |
2 ms |
620 KB |
Output is correct |
44 |
Correct |
2 ms |
620 KB |
Output is correct |
45 |
Correct |
2 ms |
620 KB |
Output is correct |
46 |
Correct |
2 ms |
620 KB |
Output is correct |
47 |
Correct |
3 ms |
620 KB |
Output is correct |
48 |
Correct |
3 ms |
620 KB |
Output is correct |
49 |
Correct |
4 ms |
620 KB |
Output is correct |
50 |
Correct |
5 ms |
620 KB |
Output is correct |
51 |
Correct |
5 ms |
620 KB |
Output is correct |
52 |
Correct |
5 ms |
620 KB |
Output is correct |
53 |
Correct |
5 ms |
620 KB |
Output is correct |
54 |
Correct |
5 ms |
620 KB |
Output is correct |
55 |
Correct |
5 ms |
620 KB |
Output is correct |
56 |
Correct |
2 ms |
620 KB |
Output is correct |
57 |
Correct |
3 ms |
620 KB |
Output is correct |
58 |
Correct |
4 ms |
620 KB |
Output is correct |
59 |
Correct |
5 ms |
620 KB |
Output is correct |
60 |
Correct |
3 ms |
620 KB |
Output is correct |
61 |
Correct |
4 ms |
620 KB |
Output is correct |
62 |
Correct |
4 ms |
620 KB |
Output is correct |
63 |
Correct |
4 ms |
620 KB |
Output is correct |
64 |
Correct |
4 ms |
620 KB |
Output is correct |
65 |
Correct |
2 ms |
620 KB |
Output is correct |
66 |
Correct |
3 ms |
620 KB |
Output is correct |
67 |
Correct |
3 ms |
620 KB |
Output is correct |
68 |
Correct |
3 ms |
620 KB |
Output is correct |
69 |
Correct |
4 ms |
624 KB |
Output is correct |
70 |
Correct |
4 ms |
624 KB |
Output is correct |
71 |
Correct |
4 ms |
624 KB |
Output is correct |
72 |
Correct |
4 ms |
624 KB |
Output is correct |
73 |
Correct |
4 ms |
624 KB |
Output is correct |
74 |
Correct |
6 ms |
624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
624 KB |
Output is correct |
2 |
Correct |
2 ms |
624 KB |
Output is correct |
3 |
Correct |
2 ms |
624 KB |
Output is correct |
4 |
Correct |
2 ms |
624 KB |
Output is correct |
5 |
Correct |
1 ms |
624 KB |
Output is correct |
6 |
Correct |
2 ms |
624 KB |
Output is correct |
7 |
Correct |
2 ms |
624 KB |
Output is correct |
8 |
Correct |
2 ms |
624 KB |
Output is correct |
9 |
Correct |
2 ms |
624 KB |
Output is correct |
10 |
Correct |
2 ms |
624 KB |
Output is correct |
11 |
Correct |
2 ms |
624 KB |
Output is correct |
12 |
Correct |
2 ms |
624 KB |
Output is correct |
13 |
Correct |
2 ms |
624 KB |
Output is correct |
14 |
Correct |
1 ms |
624 KB |
Output is correct |
15 |
Correct |
1 ms |
624 KB |
Output is correct |
16 |
Correct |
1 ms |
624 KB |
Output is correct |
17 |
Correct |
2 ms |
624 KB |
Output is correct |
18 |
Correct |
1 ms |
624 KB |
Output is correct |
19 |
Correct |
1 ms |
624 KB |
Output is correct |
20 |
Correct |
1 ms |
624 KB |
Output is correct |
21 |
Correct |
2 ms |
624 KB |
Output is correct |
22 |
Correct |
2 ms |
624 KB |
Output is correct |
23 |
Correct |
2 ms |
624 KB |
Output is correct |
24 |
Correct |
2 ms |
624 KB |
Output is correct |
25 |
Correct |
2 ms |
624 KB |
Output is correct |
26 |
Correct |
2 ms |
624 KB |
Output is correct |
27 |
Correct |
2 ms |
624 KB |
Output is correct |
28 |
Correct |
3 ms |
624 KB |
Output is correct |
29 |
Correct |
4 ms |
624 KB |
Output is correct |
30 |
Correct |
2 ms |
624 KB |
Output is correct |
31 |
Correct |
2 ms |
624 KB |
Output is correct |
32 |
Correct |
2 ms |
624 KB |
Output is correct |
33 |
Correct |
2 ms |
624 KB |
Output is correct |
34 |
Correct |
2 ms |
624 KB |
Output is correct |
35 |
Correct |
3 ms |
624 KB |
Output is correct |
36 |
Correct |
4 ms |
624 KB |
Output is correct |
37 |
Correct |
4 ms |
624 KB |
Output is correct |
38 |
Correct |
5 ms |
624 KB |
Output is correct |
39 |
Correct |
5 ms |
624 KB |
Output is correct |
40 |
Correct |
5 ms |
624 KB |
Output is correct |
41 |
Correct |
5 ms |
624 KB |
Output is correct |
42 |
Correct |
6 ms |
624 KB |
Output is correct |
43 |
Correct |
3 ms |
624 KB |
Output is correct |
44 |
Correct |
3 ms |
624 KB |
Output is correct |
45 |
Correct |
3 ms |
624 KB |
Output is correct |
46 |
Correct |
4 ms |
624 KB |
Output is correct |
47 |
Correct |
5 ms |
624 KB |
Output is correct |
48 |
Correct |
5 ms |
624 KB |
Output is correct |
49 |
Correct |
4 ms |
624 KB |
Output is correct |
50 |
Correct |
4 ms |
624 KB |
Output is correct |
51 |
Correct |
2 ms |
624 KB |
Output is correct |
52 |
Correct |
20 ms |
624 KB |
Output is correct |
53 |
Correct |
33 ms |
624 KB |
Output is correct |
54 |
Correct |
58 ms |
624 KB |
Output is correct |
55 |
Correct |
57 ms |
748 KB |
Output is correct |
56 |
Correct |
215 ms |
748 KB |
Output is correct |
57 |
Correct |
224 ms |
748 KB |
Output is correct |
58 |
Correct |
211 ms |
748 KB |
Output is correct |
59 |
Correct |
209 ms |
748 KB |
Output is correct |
60 |
Correct |
220 ms |
748 KB |
Output is correct |
61 |
Correct |
2 ms |
748 KB |
Output is correct |
62 |
Correct |
34 ms |
748 KB |
Output is correct |
63 |
Correct |
59 ms |
748 KB |
Output is correct |
64 |
Correct |
56 ms |
748 KB |
Output is correct |
65 |
Correct |
114 ms |
748 KB |
Output is correct |
66 |
Correct |
177 ms |
748 KB |
Output is correct |
67 |
Correct |
214 ms |
748 KB |
Output is correct |
68 |
Correct |
217 ms |
748 KB |
Output is correct |
69 |
Correct |
217 ms |
748 KB |
Output is correct |