#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
const int N = 2006;
const int INF = 1e9;
const ll INFLL = 1e18;
int n, a, b;
int y[N];
ll p[N];
int dp[N][N], DP[N];
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> y[i];
p[i] = p[i - 1] + y[i];
}
if (n <= 100) {
ll res = 0;
for (int bt = 42; bt >= 0; bt--) {
ll cur = (1LL << bt) | res;
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= n; i++) {
if ((p[i] & cur) == 0) {
dp[1][i] = 1;
}
}
for (int j = 2; j <= n; j++) {
for (int i = j; i <= n; i++) {
for (int k = j - 1; k < i; k++) {
ll last = p[i] - p[k];
if (dp[j - 1][k] == 1 && ((last & cur) == 0)) {
dp[j][i] = 1;
break;
}
}
}
}
int ok = 1;
for (int i = a; i <= b; i++) {
if (dp[i][n]) {
res |= (1LL << bt);
break;
}
}
}
cout << (1LL << 43) - 1 - res << endl;
} else {
ll res = 0;
for (int bt = 42; bt >= 0; bt--) {
ll cur = (1LL << bt) | res;
memset(DP, 63, sizeof(DP));
DP[0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < i; j++) {
ll last = p[i] - p[j];
if ((last & cur) == 0) {
DP[i] = min(DP[i], DP[j] + 1);
}
}
}
if (DP[n] <= b) {
res |= (1LL << bt);
}
}
cout << (1LL << 43) - 1 - res << endl;
}
return 0;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:47:17: warning: unused variable 'ok' [-Wunused-variable]
int ok = 1;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
16128 KB |
Output is correct |
2 |
Correct |
56 ms |
16128 KB |
Output is correct |
3 |
Correct |
59 ms |
16128 KB |
Output is correct |
4 |
Correct |
54 ms |
16256 KB |
Output is correct |
5 |
Correct |
64 ms |
16160 KB |
Output is correct |
6 |
Correct |
60 ms |
16152 KB |
Output is correct |
7 |
Correct |
134 ms |
16132 KB |
Output is correct |
8 |
Correct |
81 ms |
16128 KB |
Output is correct |
9 |
Correct |
102 ms |
16220 KB |
Output is correct |
10 |
Correct |
74 ms |
16128 KB |
Output is correct |
11 |
Correct |
49 ms |
16128 KB |
Output is correct |
12 |
Correct |
60 ms |
16128 KB |
Output is correct |
13 |
Correct |
52 ms |
16128 KB |
Output is correct |
14 |
Correct |
49 ms |
16128 KB |
Output is correct |
15 |
Correct |
58 ms |
16128 KB |
Output is correct |
16 |
Correct |
53 ms |
16248 KB |
Output is correct |
17 |
Correct |
51 ms |
16248 KB |
Output is correct |
18 |
Correct |
49 ms |
16120 KB |
Output is correct |
19 |
Correct |
48 ms |
16128 KB |
Output is correct |
20 |
Correct |
48 ms |
16128 KB |
Output is correct |
21 |
Correct |
46 ms |
16128 KB |
Output is correct |
22 |
Correct |
119 ms |
16128 KB |
Output is correct |
23 |
Correct |
92 ms |
16248 KB |
Output is correct |
24 |
Correct |
98 ms |
16036 KB |
Output is correct |
25 |
Correct |
69 ms |
16000 KB |
Output is correct |
26 |
Correct |
48 ms |
16128 KB |
Output is correct |
27 |
Correct |
92 ms |
16248 KB |
Output is correct |
28 |
Correct |
49 ms |
16128 KB |
Output is correct |
29 |
Correct |
50 ms |
16128 KB |
Output is correct |
30 |
Correct |
53 ms |
16128 KB |
Output is correct |
31 |
Correct |
51 ms |
16128 KB |
Output is correct |
32 |
Correct |
130 ms |
16128 KB |
Output is correct |
33 |
Correct |
50 ms |
16248 KB |
Output is correct |
34 |
Correct |
50 ms |
16128 KB |
Output is correct |
35 |
Correct |
53 ms |
16128 KB |
Output is correct |
36 |
Correct |
50 ms |
16128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
16128 KB |
Output is correct |
2 |
Correct |
58 ms |
16128 KB |
Output is correct |
3 |
Correct |
140 ms |
16248 KB |
Output is correct |
4 |
Correct |
75 ms |
16128 KB |
Output is correct |
5 |
Correct |
141 ms |
16132 KB |
Output is correct |
6 |
Correct |
97 ms |
16128 KB |
Output is correct |
7 |
Correct |
108 ms |
16136 KB |
Output is correct |
8 |
Correct |
52 ms |
16128 KB |
Output is correct |
9 |
Correct |
59 ms |
16128 KB |
Output is correct |
10 |
Correct |
53 ms |
16128 KB |
Output is correct |
11 |
Correct |
90 ms |
16128 KB |
Output is correct |
12 |
Correct |
120 ms |
16128 KB |
Output is correct |
13 |
Correct |
53 ms |
16128 KB |
Output is correct |
14 |
Correct |
56 ms |
16128 KB |
Output is correct |
15 |
Correct |
54 ms |
16084 KB |
Output is correct |
16 |
Correct |
50 ms |
16128 KB |
Output is correct |
17 |
Correct |
55 ms |
16128 KB |
Output is correct |
18 |
Correct |
50 ms |
16128 KB |
Output is correct |
19 |
Correct |
52 ms |
16128 KB |
Output is correct |
20 |
Correct |
57 ms |
16248 KB |
Output is correct |
21 |
Correct |
51 ms |
16256 KB |
Output is correct |
22 |
Correct |
64 ms |
16248 KB |
Output is correct |
23 |
Correct |
50 ms |
16128 KB |
Output is correct |
24 |
Correct |
73 ms |
16128 KB |
Output is correct |
25 |
Correct |
51 ms |
16128 KB |
Output is correct |
26 |
Correct |
121 ms |
16136 KB |
Output is correct |
27 |
Correct |
54 ms |
16128 KB |
Output is correct |
28 |
Correct |
51 ms |
16128 KB |
Output is correct |
29 |
Correct |
54 ms |
16128 KB |
Output is correct |
30 |
Correct |
131 ms |
16128 KB |
Output is correct |
31 |
Correct |
57 ms |
16128 KB |
Output is correct |
32 |
Correct |
60 ms |
16248 KB |
Output is correct |
33 |
Correct |
131 ms |
16128 KB |
Output is correct |
34 |
Correct |
94 ms |
16128 KB |
Output is correct |
35 |
Correct |
133 ms |
16268 KB |
Output is correct |
36 |
Correct |
131 ms |
16128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
16128 KB |
Output is correct |
2 |
Correct |
155 ms |
16128 KB |
Output is correct |
3 |
Correct |
127 ms |
16128 KB |
Output is correct |
4 |
Correct |
120 ms |
16128 KB |
Output is correct |
5 |
Correct |
58 ms |
16136 KB |
Output is correct |
6 |
Correct |
58 ms |
16128 KB |
Output is correct |
7 |
Correct |
76 ms |
16044 KB |
Output is correct |
8 |
Correct |
52 ms |
16128 KB |
Output is correct |
9 |
Correct |
55 ms |
16128 KB |
Output is correct |
10 |
Correct |
121 ms |
16172 KB |
Output is correct |
11 |
Correct |
53 ms |
16128 KB |
Output is correct |
12 |
Correct |
53 ms |
16128 KB |
Output is correct |
13 |
Correct |
83 ms |
16128 KB |
Output is correct |
14 |
Correct |
71 ms |
16128 KB |
Output is correct |
15 |
Correct |
58 ms |
16248 KB |
Output is correct |
16 |
Correct |
65 ms |
16128 KB |
Output is correct |
17 |
Correct |
63 ms |
16248 KB |
Output is correct |
18 |
Correct |
92 ms |
16128 KB |
Output is correct |
19 |
Correct |
84 ms |
16128 KB |
Output is correct |
20 |
Correct |
132 ms |
16128 KB |
Output is correct |
21 |
Correct |
61 ms |
16128 KB |
Output is correct |
22 |
Correct |
55 ms |
16128 KB |
Output is correct |
23 |
Correct |
57 ms |
16128 KB |
Output is correct |
24 |
Correct |
130 ms |
16128 KB |
Output is correct |
25 |
Correct |
120 ms |
16128 KB |
Output is correct |
26 |
Correct |
49 ms |
16128 KB |
Output is correct |
27 |
Correct |
50 ms |
16128 KB |
Output is correct |
28 |
Correct |
53 ms |
16128 KB |
Output is correct |
29 |
Correct |
63 ms |
16128 KB |
Output is correct |
30 |
Correct |
59 ms |
16128 KB |
Output is correct |
31 |
Correct |
74 ms |
16024 KB |
Output is correct |
32 |
Correct |
70 ms |
16128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
16136 KB |
Output is correct |
2 |
Correct |
94 ms |
16128 KB |
Output is correct |
3 |
Correct |
156 ms |
16248 KB |
Output is correct |
4 |
Correct |
138 ms |
16136 KB |
Output is correct |
5 |
Correct |
152 ms |
16248 KB |
Output is correct |
6 |
Correct |
128 ms |
16132 KB |
Output is correct |
7 |
Correct |
73 ms |
16128 KB |
Output is correct |
8 |
Correct |
64 ms |
16128 KB |
Output is correct |
9 |
Correct |
59 ms |
16128 KB |
Output is correct |
10 |
Correct |
60 ms |
16128 KB |
Output is correct |
11 |
Correct |
52 ms |
16128 KB |
Output is correct |
12 |
Correct |
50 ms |
16248 KB |
Output is correct |
13 |
Correct |
62 ms |
16128 KB |
Output is correct |
14 |
Correct |
51 ms |
16128 KB |
Output is correct |
15 |
Correct |
53 ms |
16128 KB |
Output is correct |
16 |
Correct |
54 ms |
16248 KB |
Output is correct |
17 |
Correct |
51 ms |
16128 KB |
Output is correct |
18 |
Correct |
139 ms |
16132 KB |
Output is correct |
19 |
Correct |
93 ms |
16248 KB |
Output is correct |
20 |
Correct |
51 ms |
16128 KB |
Output is correct |
21 |
Correct |
119 ms |
16128 KB |
Output is correct |
22 |
Correct |
52 ms |
16128 KB |
Output is correct |
23 |
Correct |
61 ms |
16128 KB |
Output is correct |
24 |
Correct |
52 ms |
16128 KB |
Output is correct |
25 |
Correct |
193 ms |
16132 KB |
Output is correct |
26 |
Correct |
174 ms |
16248 KB |
Output is correct |
27 |
Correct |
49 ms |
16128 KB |
Output is correct |
28 |
Correct |
58 ms |
16172 KB |
Output is correct |
29 |
Correct |
56 ms |
16132 KB |
Output is correct |
30 |
Correct |
141 ms |
16136 KB |
Output is correct |
31 |
Correct |
89 ms |
16128 KB |
Output is correct |
32 |
Correct |
129 ms |
16096 KB |
Output is correct |
33 |
Correct |
105 ms |
16172 KB |
Output is correct |
34 |
Correct |
50 ms |
16128 KB |
Output is correct |
35 |
Correct |
48 ms |
16128 KB |
Output is correct |
36 |
Correct |
58 ms |
16128 KB |
Output is correct |
37 |
Correct |
147 ms |
16140 KB |
Output is correct |
38 |
Correct |
122 ms |
16248 KB |
Output is correct |
39 |
Correct |
75 ms |
16128 KB |
Output is correct |
40 |
Correct |
90 ms |
16248 KB |
Output is correct |
41 |
Correct |
58 ms |
16128 KB |
Output is correct |
42 |
Correct |
104 ms |
16128 KB |
Output is correct |
43 |
Correct |
109 ms |
16248 KB |
Output is correct |
44 |
Correct |
52 ms |
16140 KB |
Output is correct |
45 |
Correct |
55 ms |
16140 KB |
Output is correct |
46 |
Correct |
49 ms |
16128 KB |
Output is correct |
47 |
Correct |
83 ms |
16172 KB |
Output is correct |
48 |
Correct |
92 ms |
16128 KB |
Output is correct |
49 |
Correct |
112 ms |
16128 KB |
Output is correct |
50 |
Correct |
86 ms |
16128 KB |
Output is correct |
51 |
Correct |
99 ms |
16248 KB |
Output is correct |
52 |
Correct |
100 ms |
16128 KB |
Output is correct |
53 |
Correct |
129 ms |
16256 KB |
Output is correct |
54 |
Correct |
84 ms |
16132 KB |
Output is correct |
55 |
Correct |
66 ms |
16248 KB |
Output is correct |
56 |
Correct |
59 ms |
16128 KB |
Output is correct |
57 |
Correct |
112 ms |
16128 KB |
Output is correct |
58 |
Correct |
97 ms |
16120 KB |
Output is correct |
59 |
Correct |
72 ms |
16128 KB |
Output is correct |
60 |
Correct |
125 ms |
16248 KB |
Output is correct |
61 |
Correct |
138 ms |
16248 KB |
Output is correct |
62 |
Correct |
60 ms |
16128 KB |
Output is correct |
63 |
Correct |
111 ms |
16248 KB |
Output is correct |
64 |
Correct |
157 ms |
16128 KB |
Output is correct |
65 |
Correct |
107 ms |
16128 KB |
Output is correct |
66 |
Correct |
132 ms |
16200 KB |
Output is correct |
67 |
Correct |
113 ms |
16144 KB |
Output is correct |
68 |
Correct |
110 ms |
16120 KB |
Output is correct |
69 |
Correct |
171 ms |
16120 KB |
Output is correct |
70 |
Correct |
142 ms |
16204 KB |
Output is correct |
71 |
Correct |
96 ms |
16128 KB |
Output is correct |
72 |
Correct |
72 ms |
16128 KB |
Output is correct |
73 |
Correct |
133 ms |
16128 KB |
Output is correct |
74 |
Correct |
124 ms |
16136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
16132 KB |
Output is correct |
2 |
Correct |
111 ms |
16140 KB |
Output is correct |
3 |
Correct |
90 ms |
16128 KB |
Output is correct |
4 |
Correct |
91 ms |
16128 KB |
Output is correct |
5 |
Correct |
107 ms |
16120 KB |
Output is correct |
6 |
Correct |
141 ms |
16132 KB |
Output is correct |
7 |
Correct |
139 ms |
16248 KB |
Output is correct |
8 |
Correct |
90 ms |
16208 KB |
Output is correct |
9 |
Correct |
86 ms |
16120 KB |
Output is correct |
10 |
Correct |
100 ms |
16128 KB |
Output is correct |
11 |
Correct |
121 ms |
16116 KB |
Output is correct |
12 |
Correct |
120 ms |
16188 KB |
Output is correct |
13 |
Correct |
136 ms |
16140 KB |
Output is correct |
14 |
Correct |
143 ms |
16128 KB |
Output is correct |
15 |
Correct |
148 ms |
16148 KB |
Output is correct |
16 |
Correct |
107 ms |
16220 KB |
Output is correct |
17 |
Correct |
128 ms |
16144 KB |
Output is correct |
18 |
Correct |
133 ms |
16128 KB |
Output is correct |
19 |
Correct |
126 ms |
16132 KB |
Output is correct |
20 |
Correct |
113 ms |
16136 KB |
Output is correct |
21 |
Correct |
102 ms |
16248 KB |
Output is correct |
22 |
Correct |
48 ms |
16128 KB |
Output is correct |
23 |
Correct |
49 ms |
16128 KB |
Output is correct |
24 |
Correct |
156 ms |
16120 KB |
Output is correct |
25 |
Correct |
176 ms |
16284 KB |
Output is correct |
26 |
Correct |
126 ms |
16248 KB |
Output is correct |
27 |
Correct |
117 ms |
16176 KB |
Output is correct |
28 |
Correct |
82 ms |
16172 KB |
Output is correct |
29 |
Correct |
121 ms |
16248 KB |
Output is correct |
30 |
Correct |
61 ms |
16128 KB |
Output is correct |
31 |
Correct |
53 ms |
16128 KB |
Output is correct |
32 |
Correct |
119 ms |
16128 KB |
Output is correct |
33 |
Correct |
62 ms |
16048 KB |
Output is correct |
34 |
Correct |
56 ms |
16128 KB |
Output is correct |
35 |
Correct |
115 ms |
16248 KB |
Output is correct |
36 |
Correct |
187 ms |
16248 KB |
Output is correct |
37 |
Correct |
57 ms |
16128 KB |
Output is correct |
38 |
Correct |
58 ms |
16128 KB |
Output is correct |
39 |
Correct |
52 ms |
16128 KB |
Output is correct |
40 |
Correct |
57 ms |
16248 KB |
Output is correct |
41 |
Correct |
65 ms |
16248 KB |
Output is correct |
42 |
Correct |
156 ms |
16248 KB |
Output is correct |
43 |
Correct |
103 ms |
16128 KB |
Output is correct |
44 |
Correct |
115 ms |
16136 KB |
Output is correct |
45 |
Correct |
137 ms |
16128 KB |
Output is correct |
46 |
Correct |
127 ms |
16128 KB |
Output is correct |
47 |
Correct |
122 ms |
16128 KB |
Output is correct |
48 |
Correct |
83 ms |
16128 KB |
Output is correct |
49 |
Correct |
96 ms |
16248 KB |
Output is correct |
50 |
Correct |
118 ms |
16128 KB |
Output is correct |
51 |
Correct |
2 ms |
384 KB |
Output is correct |
52 |
Correct |
10 ms |
384 KB |
Output is correct |
53 |
Correct |
15 ms |
384 KB |
Output is correct |
54 |
Correct |
29 ms |
452 KB |
Output is correct |
55 |
Correct |
24 ms |
432 KB |
Output is correct |
56 |
Correct |
99 ms |
416 KB |
Output is correct |
57 |
Correct |
96 ms |
504 KB |
Output is correct |
58 |
Correct |
89 ms |
384 KB |
Output is correct |
59 |
Correct |
81 ms |
384 KB |
Output is correct |
60 |
Correct |
88 ms |
504 KB |
Output is correct |
61 |
Correct |
2 ms |
384 KB |
Output is correct |
62 |
Correct |
14 ms |
384 KB |
Output is correct |
63 |
Correct |
26 ms |
384 KB |
Output is correct |
64 |
Correct |
27 ms |
384 KB |
Output is correct |
65 |
Correct |
47 ms |
420 KB |
Output is correct |
66 |
Correct |
63 ms |
384 KB |
Output is correct |
67 |
Correct |
83 ms |
384 KB |
Output is correct |
68 |
Correct |
86 ms |
384 KB |
Output is correct |
69 |
Correct |
81 ms |
384 KB |
Output is correct |