#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;
const int MAXN = 2010;
ll arr[MAXN], pref[MAXN];
int n, a, b;
int dp[MAXN];
ll out = 0;
int dp2[MAXN][MAXN];
ll val(ll sum) {
return ((((1LL << 60) - 1) - out) & sum);
}
int solve(int x) {
REP(i, n) {
dp[i] = 1e9;
if (val(pref[i]) < (1LL << x)) dp[i] = 1;
REP(j, i) {
if (val(pref[i] - pref[j]) < (1LL << x)) dp[i] = min(dp[i], dp[j] + 1);
}
}
return dp[n - 1];
}
void solve2(int x) {
REP(i, n + 1) {
dp2[i][1] = 0;
if (val(pref[i]) < (1LL << x)) dp2[i][1] = 1;
FOR(j, 2, n + 1) {
dp2[i][j] = 0;
REP(k, i) {
if (val(pref[i] - pref[k]) < (1LL << x)) dp2[i][j] = max(dp2[i][j], dp2[k][j - 1]);
}
}
}
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> a >> b;
REP(i, n) cin >> arr[i];
REP(i, n) {
pref[i] = arr[i];
if (i) pref[i] += pref[i - 1];
}
/*if (a == 1) {
FORd(i, 50, 0) {
if (solve(i) > b) out |= (1LL << i);
}
cout << out << "\n";
} else {*/
FORd(i, 50, 0) {
solve2(i);
int fl = 0;
FOR(j, a, b + 1) fl = max(fl, dp2[n - 1][j]);
if (!fl) out |= (1LL << i);
}
cout << out << "\n";
//}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
3 ms |
512 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
3 ms |
380 KB |
Output is correct |
36 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
556 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
484 KB |
Output is correct |
28 |
Correct |
5 ms |
512 KB |
Output is correct |
29 |
Correct |
6 ms |
512 KB |
Output is correct |
30 |
Correct |
5 ms |
512 KB |
Output is correct |
31 |
Correct |
11 ms |
640 KB |
Output is correct |
32 |
Correct |
9 ms |
640 KB |
Output is correct |
33 |
Correct |
8 ms |
512 KB |
Output is correct |
34 |
Correct |
8 ms |
640 KB |
Output is correct |
35 |
Correct |
8 ms |
640 KB |
Output is correct |
36 |
Correct |
11 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
356 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
556 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
512 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
10 ms |
640 KB |
Output is correct |
19 |
Correct |
8 ms |
640 KB |
Output is correct |
20 |
Correct |
9 ms |
640 KB |
Output is correct |
21 |
Correct |
8 ms |
640 KB |
Output is correct |
22 |
Correct |
9 ms |
512 KB |
Output is correct |
23 |
Correct |
8 ms |
640 KB |
Output is correct |
24 |
Correct |
9 ms |
512 KB |
Output is correct |
25 |
Correct |
19 ms |
640 KB |
Output is correct |
26 |
Correct |
42 ms |
768 KB |
Output is correct |
27 |
Correct |
54 ms |
780 KB |
Output is correct |
28 |
Correct |
63 ms |
740 KB |
Output is correct |
29 |
Correct |
66 ms |
768 KB |
Output is correct |
30 |
Correct |
67 ms |
888 KB |
Output is correct |
31 |
Correct |
54 ms |
768 KB |
Output is correct |
32 |
Correct |
63 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
3 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
484 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
4 ms |
512 KB |
Output is correct |
35 |
Correct |
3 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
1 ms |
512 KB |
Output is correct |
38 |
Correct |
2 ms |
384 KB |
Output is correct |
39 |
Correct |
5 ms |
512 KB |
Output is correct |
40 |
Correct |
6 ms |
512 KB |
Output is correct |
41 |
Correct |
8 ms |
640 KB |
Output is correct |
42 |
Correct |
8 ms |
512 KB |
Output is correct |
43 |
Correct |
9 ms |
640 KB |
Output is correct |
44 |
Correct |
9 ms |
640 KB |
Output is correct |
45 |
Correct |
9 ms |
512 KB |
Output is correct |
46 |
Correct |
10 ms |
512 KB |
Output is correct |
47 |
Correct |
8 ms |
512 KB |
Output is correct |
48 |
Correct |
17 ms |
640 KB |
Output is correct |
49 |
Correct |
27 ms |
640 KB |
Output is correct |
50 |
Correct |
48 ms |
784 KB |
Output is correct |
51 |
Correct |
59 ms |
820 KB |
Output is correct |
52 |
Correct |
60 ms |
768 KB |
Output is correct |
53 |
Correct |
67 ms |
768 KB |
Output is correct |
54 |
Correct |
60 ms |
768 KB |
Output is correct |
55 |
Correct |
60 ms |
812 KB |
Output is correct |
56 |
Correct |
9 ms |
640 KB |
Output is correct |
57 |
Correct |
22 ms |
768 KB |
Output is correct |
58 |
Correct |
38 ms |
768 KB |
Output is correct |
59 |
Correct |
52 ms |
828 KB |
Output is correct |
60 |
Correct |
49 ms |
828 KB |
Output is correct |
61 |
Correct |
42 ms |
768 KB |
Output is correct |
62 |
Correct |
62 ms |
816 KB |
Output is correct |
63 |
Correct |
52 ms |
816 KB |
Output is correct |
64 |
Correct |
51 ms |
776 KB |
Output is correct |
65 |
Correct |
10 ms |
612 KB |
Output is correct |
66 |
Correct |
13 ms |
640 KB |
Output is correct |
67 |
Correct |
26 ms |
640 KB |
Output is correct |
68 |
Correct |
32 ms |
860 KB |
Output is correct |
69 |
Correct |
44 ms |
824 KB |
Output is correct |
70 |
Correct |
44 ms |
816 KB |
Output is correct |
71 |
Correct |
49 ms |
832 KB |
Output is correct |
72 |
Correct |
55 ms |
768 KB |
Output is correct |
73 |
Correct |
48 ms |
888 KB |
Output is correct |
74 |
Correct |
39 ms |
824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
356 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
3 ms |
512 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
552 KB |
Output is correct |
27 |
Correct |
7 ms |
504 KB |
Output is correct |
28 |
Correct |
9 ms |
608 KB |
Output is correct |
29 |
Correct |
9 ms |
604 KB |
Output is correct |
30 |
Correct |
8 ms |
556 KB |
Output is correct |
31 |
Correct |
9 ms |
512 KB |
Output is correct |
32 |
Correct |
11 ms |
516 KB |
Output is correct |
33 |
Correct |
10 ms |
512 KB |
Output is correct |
34 |
Correct |
10 ms |
640 KB |
Output is correct |
35 |
Correct |
20 ms |
760 KB |
Output is correct |
36 |
Correct |
32 ms |
732 KB |
Output is correct |
37 |
Correct |
59 ms |
780 KB |
Output is correct |
38 |
Correct |
62 ms |
812 KB |
Output is correct |
39 |
Correct |
75 ms |
816 KB |
Output is correct |
40 |
Correct |
60 ms |
824 KB |
Output is correct |
41 |
Correct |
69 ms |
824 KB |
Output is correct |
42 |
Correct |
61 ms |
768 KB |
Output is correct |
43 |
Correct |
8 ms |
512 KB |
Output is correct |
44 |
Correct |
27 ms |
740 KB |
Output is correct |
45 |
Correct |
31 ms |
792 KB |
Output is correct |
46 |
Correct |
44 ms |
832 KB |
Output is correct |
47 |
Correct |
45 ms |
856 KB |
Output is correct |
48 |
Correct |
37 ms |
828 KB |
Output is correct |
49 |
Correct |
42 ms |
740 KB |
Output is correct |
50 |
Correct |
41 ms |
816 KB |
Output is correct |
51 |
Correct |
45 ms |
832 KB |
Output is correct |
52 |
Execution timed out |
1070 ms |
3900 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |