#include <bits/stdc++.h>
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long
using namespace std;
typedef long long ll;
const long long inf = (long long)1e15 + 7;
const long long N = (long long)2e5 + 7;
long long n,a,b;
long long ar[N],p[N];
set<int> dp[2002][2002];
long long mn = inf;
long long calc (long long l,long long r) {
return (p[r] - p[l - 1]);
}
main () {
cin >> n >> a >> b;
for (long long i = 1; i <= n; i ++) {
cin >> ar[i];
p[i] = p[i - 1] + ar[i];
dp[i][1].insert(p[i]);
}
for (long long j = 2; j <= b; j ++) {
for (long long i = j; i <= n; i ++) {
for (long long l = 1; l < i; l ++) {
for (auto to : dp[l][j - 1]) {
dp[i][j].insert(to | calc(l + 1,i));
}
}
}
}
for (long long i = a; i <= b; i ++) {
for (auto to : dp[n][i])
mn = min(mn,to);
}
cout << mn << endl;
}
/**
6 1 3
8 1 2 1 5 4
**/
Compilation message
sculpture.cpp:26:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
146 ms |
188536 KB |
Output is correct |
2 |
Correct |
150 ms |
188644 KB |
Output is correct |
3 |
Correct |
167 ms |
188720 KB |
Output is correct |
4 |
Correct |
149 ms |
188888 KB |
Output is correct |
5 |
Correct |
156 ms |
188888 KB |
Output is correct |
6 |
Correct |
167 ms |
188888 KB |
Output is correct |
7 |
Correct |
158 ms |
188888 KB |
Output is correct |
8 |
Correct |
171 ms |
188956 KB |
Output is correct |
9 |
Correct |
153 ms |
188956 KB |
Output is correct |
10 |
Correct |
155 ms |
188956 KB |
Output is correct |
11 |
Correct |
156 ms |
188956 KB |
Output is correct |
12 |
Correct |
154 ms |
188956 KB |
Output is correct |
13 |
Correct |
165 ms |
189024 KB |
Output is correct |
14 |
Correct |
161 ms |
189192 KB |
Output is correct |
15 |
Correct |
176 ms |
189192 KB |
Output is correct |
16 |
Correct |
183 ms |
189192 KB |
Output is correct |
17 |
Correct |
159 ms |
189192 KB |
Output is correct |
18 |
Correct |
186 ms |
189208 KB |
Output is correct |
19 |
Correct |
158 ms |
189208 KB |
Output is correct |
20 |
Correct |
160 ms |
189208 KB |
Output is correct |
21 |
Correct |
183 ms |
189208 KB |
Output is correct |
22 |
Correct |
157 ms |
189208 KB |
Output is correct |
23 |
Correct |
187 ms |
189208 KB |
Output is correct |
24 |
Correct |
189 ms |
189208 KB |
Output is correct |
25 |
Correct |
177 ms |
189208 KB |
Output is correct |
26 |
Correct |
155 ms |
189208 KB |
Output is correct |
27 |
Correct |
181 ms |
189208 KB |
Output is correct |
28 |
Correct |
155 ms |
189208 KB |
Output is correct |
29 |
Correct |
165 ms |
189208 KB |
Output is correct |
30 |
Correct |
182 ms |
189208 KB |
Output is correct |
31 |
Correct |
154 ms |
189208 KB |
Output is correct |
32 |
Correct |
184 ms |
189208 KB |
Output is correct |
33 |
Correct |
183 ms |
189208 KB |
Output is correct |
34 |
Correct |
169 ms |
189208 KB |
Output is correct |
35 |
Correct |
167 ms |
189208 KB |
Output is correct |
36 |
Correct |
153 ms |
189208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
173 ms |
189208 KB |
Output is correct |
2 |
Correct |
162 ms |
189208 KB |
Output is correct |
3 |
Correct |
151 ms |
189208 KB |
Output is correct |
4 |
Correct |
153 ms |
189208 KB |
Output is correct |
5 |
Correct |
155 ms |
189208 KB |
Output is correct |
6 |
Correct |
154 ms |
189208 KB |
Output is correct |
7 |
Correct |
158 ms |
189208 KB |
Output is correct |
8 |
Correct |
156 ms |
189208 KB |
Output is correct |
9 |
Correct |
153 ms |
189208 KB |
Output is correct |
10 |
Correct |
158 ms |
189208 KB |
Output is correct |
11 |
Correct |
155 ms |
189208 KB |
Output is correct |
12 |
Correct |
156 ms |
189208 KB |
Output is correct |
13 |
Correct |
157 ms |
189208 KB |
Output is correct |
14 |
Correct |
158 ms |
189208 KB |
Output is correct |
15 |
Correct |
153 ms |
189208 KB |
Output is correct |
16 |
Correct |
165 ms |
189208 KB |
Output is correct |
17 |
Correct |
156 ms |
189208 KB |
Output is correct |
18 |
Correct |
161 ms |
189208 KB |
Output is correct |
19 |
Correct |
157 ms |
189216 KB |
Output is correct |
20 |
Correct |
150 ms |
189216 KB |
Output is correct |
21 |
Correct |
150 ms |
189232 KB |
Output is correct |
22 |
Correct |
173 ms |
189236 KB |
Output is correct |
23 |
Correct |
159 ms |
189236 KB |
Output is correct |
24 |
Correct |
151 ms |
189236 KB |
Output is correct |
25 |
Correct |
150 ms |
189248 KB |
Output is correct |
26 |
Correct |
153 ms |
189248 KB |
Output is correct |
27 |
Correct |
149 ms |
189384 KB |
Output is correct |
28 |
Correct |
151 ms |
189384 KB |
Output is correct |
29 |
Correct |
150 ms |
189384 KB |
Output is correct |
30 |
Correct |
157 ms |
189780 KB |
Output is correct |
31 |
Correct |
170 ms |
190296 KB |
Output is correct |
32 |
Correct |
164 ms |
190296 KB |
Output is correct |
33 |
Correct |
149 ms |
190296 KB |
Output is correct |
34 |
Correct |
163 ms |
190296 KB |
Output is correct |
35 |
Correct |
161 ms |
190296 KB |
Output is correct |
36 |
Correct |
158 ms |
190296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
154 ms |
190296 KB |
Output is correct |
2 |
Correct |
150 ms |
190296 KB |
Output is correct |
3 |
Correct |
175 ms |
190296 KB |
Output is correct |
4 |
Correct |
152 ms |
190296 KB |
Output is correct |
5 |
Correct |
151 ms |
190296 KB |
Output is correct |
6 |
Correct |
151 ms |
190296 KB |
Output is correct |
7 |
Correct |
151 ms |
190296 KB |
Output is correct |
8 |
Correct |
154 ms |
190296 KB |
Output is correct |
9 |
Correct |
156 ms |
190296 KB |
Output is correct |
10 |
Correct |
150 ms |
190296 KB |
Output is correct |
11 |
Correct |
155 ms |
190296 KB |
Output is correct |
12 |
Correct |
146 ms |
190296 KB |
Output is correct |
13 |
Correct |
161 ms |
190296 KB |
Output is correct |
14 |
Correct |
152 ms |
190296 KB |
Output is correct |
15 |
Correct |
153 ms |
190296 KB |
Output is correct |
16 |
Correct |
151 ms |
190296 KB |
Output is correct |
17 |
Correct |
159 ms |
190296 KB |
Output is correct |
18 |
Correct |
171 ms |
190388 KB |
Output is correct |
19 |
Correct |
196 ms |
190388 KB |
Output is correct |
20 |
Correct |
150 ms |
190388 KB |
Output is correct |
21 |
Correct |
164 ms |
190388 KB |
Output is correct |
22 |
Correct |
161 ms |
190388 KB |
Output is correct |
23 |
Correct |
174 ms |
190388 KB |
Output is correct |
24 |
Correct |
174 ms |
190684 KB |
Output is correct |
25 |
Correct |
187 ms |
190832 KB |
Output is correct |
26 |
Correct |
282 ms |
193888 KB |
Output is correct |
27 |
Correct |
399 ms |
197436 KB |
Output is correct |
28 |
Correct |
520 ms |
200396 KB |
Output is correct |
29 |
Correct |
379 ms |
200396 KB |
Output is correct |
30 |
Correct |
150 ms |
200396 KB |
Output is correct |
31 |
Correct |
579 ms |
201332 KB |
Output is correct |
32 |
Correct |
617 ms |
202084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
171 ms |
202084 KB |
Output is correct |
2 |
Correct |
152 ms |
202084 KB |
Output is correct |
3 |
Correct |
153 ms |
202084 KB |
Output is correct |
4 |
Correct |
179 ms |
202084 KB |
Output is correct |
5 |
Correct |
150 ms |
202084 KB |
Output is correct |
6 |
Correct |
153 ms |
202084 KB |
Output is correct |
7 |
Correct |
152 ms |
202084 KB |
Output is correct |
8 |
Correct |
149 ms |
202084 KB |
Output is correct |
9 |
Correct |
153 ms |
202084 KB |
Output is correct |
10 |
Correct |
168 ms |
202084 KB |
Output is correct |
11 |
Correct |
151 ms |
202084 KB |
Output is correct |
12 |
Correct |
151 ms |
202084 KB |
Output is correct |
13 |
Correct |
148 ms |
202084 KB |
Output is correct |
14 |
Correct |
175 ms |
202084 KB |
Output is correct |
15 |
Correct |
150 ms |
202084 KB |
Output is correct |
16 |
Correct |
149 ms |
202084 KB |
Output is correct |
17 |
Correct |
154 ms |
202084 KB |
Output is correct |
18 |
Correct |
151 ms |
202084 KB |
Output is correct |
19 |
Correct |
150 ms |
202084 KB |
Output is correct |
20 |
Correct |
153 ms |
202084 KB |
Output is correct |
21 |
Correct |
148 ms |
202084 KB |
Output is correct |
22 |
Correct |
148 ms |
202084 KB |
Output is correct |
23 |
Correct |
155 ms |
202084 KB |
Output is correct |
24 |
Correct |
150 ms |
202084 KB |
Output is correct |
25 |
Correct |
152 ms |
202084 KB |
Output is correct |
26 |
Correct |
158 ms |
202084 KB |
Output is correct |
27 |
Correct |
159 ms |
202084 KB |
Output is correct |
28 |
Correct |
150 ms |
202084 KB |
Output is correct |
29 |
Correct |
153 ms |
202084 KB |
Output is correct |
30 |
Correct |
153 ms |
202084 KB |
Output is correct |
31 |
Correct |
153 ms |
202084 KB |
Output is correct |
32 |
Correct |
152 ms |
202084 KB |
Output is correct |
33 |
Correct |
151 ms |
202084 KB |
Output is correct |
34 |
Correct |
155 ms |
202084 KB |
Output is correct |
35 |
Correct |
152 ms |
202084 KB |
Output is correct |
36 |
Correct |
150 ms |
202084 KB |
Output is correct |
37 |
Correct |
155 ms |
202084 KB |
Output is correct |
38 |
Correct |
157 ms |
202084 KB |
Output is correct |
39 |
Correct |
154 ms |
202084 KB |
Output is correct |
40 |
Correct |
168 ms |
202084 KB |
Output is correct |
41 |
Correct |
189 ms |
202084 KB |
Output is correct |
42 |
Correct |
170 ms |
202084 KB |
Output is correct |
43 |
Correct |
160 ms |
202084 KB |
Output is correct |
44 |
Correct |
184 ms |
202084 KB |
Output is correct |
45 |
Correct |
174 ms |
202084 KB |
Output is correct |
46 |
Correct |
177 ms |
202084 KB |
Output is correct |
47 |
Correct |
205 ms |
202084 KB |
Output is correct |
48 |
Correct |
215 ms |
202084 KB |
Output is correct |
49 |
Correct |
299 ms |
202084 KB |
Output is correct |
50 |
Correct |
403 ms |
202084 KB |
Output is correct |
51 |
Correct |
555 ms |
202084 KB |
Output is correct |
52 |
Correct |
370 ms |
202084 KB |
Output is correct |
53 |
Correct |
164 ms |
202084 KB |
Output is correct |
54 |
Correct |
601 ms |
202084 KB |
Output is correct |
55 |
Correct |
598 ms |
202360 KB |
Output is correct |
56 |
Correct |
977 ms |
224864 KB |
Output is correct |
57 |
Execution timed out |
1100 ms |
232432 KB |
Time limit exceeded |
58 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
154 ms |
232432 KB |
Output is correct |
2 |
Correct |
158 ms |
232432 KB |
Output is correct |
3 |
Correct |
163 ms |
232432 KB |
Output is correct |
4 |
Correct |
166 ms |
232432 KB |
Output is correct |
5 |
Correct |
162 ms |
232432 KB |
Output is correct |
6 |
Correct |
159 ms |
232432 KB |
Output is correct |
7 |
Correct |
157 ms |
232432 KB |
Output is correct |
8 |
Correct |
156 ms |
232432 KB |
Output is correct |
9 |
Correct |
157 ms |
232432 KB |
Output is correct |
10 |
Correct |
162 ms |
232432 KB |
Output is correct |
11 |
Correct |
157 ms |
232432 KB |
Output is correct |
12 |
Correct |
171 ms |
232432 KB |
Output is correct |
13 |
Correct |
161 ms |
232432 KB |
Output is correct |
14 |
Correct |
152 ms |
232432 KB |
Output is correct |
15 |
Correct |
172 ms |
232432 KB |
Output is correct |
16 |
Correct |
165 ms |
232432 KB |
Output is correct |
17 |
Correct |
150 ms |
232432 KB |
Output is correct |
18 |
Correct |
154 ms |
232432 KB |
Output is correct |
19 |
Correct |
155 ms |
232432 KB |
Output is correct |
20 |
Correct |
160 ms |
232432 KB |
Output is correct |
21 |
Correct |
161 ms |
232432 KB |
Output is correct |
22 |
Correct |
180 ms |
232432 KB |
Output is correct |
23 |
Correct |
177 ms |
232432 KB |
Output is correct |
24 |
Correct |
152 ms |
232432 KB |
Output is correct |
25 |
Correct |
151 ms |
232432 KB |
Output is correct |
26 |
Correct |
156 ms |
232432 KB |
Output is correct |
27 |
Correct |
155 ms |
232432 KB |
Output is correct |
28 |
Correct |
168 ms |
232432 KB |
Output is correct |
29 |
Correct |
160 ms |
232432 KB |
Output is correct |
30 |
Correct |
155 ms |
232432 KB |
Output is correct |
31 |
Correct |
164 ms |
232432 KB |
Output is correct |
32 |
Correct |
164 ms |
232432 KB |
Output is correct |
33 |
Correct |
195 ms |
232432 KB |
Output is correct |
34 |
Correct |
173 ms |
232432 KB |
Output is correct |
35 |
Correct |
196 ms |
232432 KB |
Output is correct |
36 |
Correct |
284 ms |
232432 KB |
Output is correct |
37 |
Correct |
398 ms |
232432 KB |
Output is correct |
38 |
Correct |
516 ms |
232432 KB |
Output is correct |
39 |
Correct |
377 ms |
232432 KB |
Output is correct |
40 |
Correct |
163 ms |
232432 KB |
Output is correct |
41 |
Correct |
592 ms |
232432 KB |
Output is correct |
42 |
Correct |
594 ms |
232432 KB |
Output is correct |
43 |
Correct |
937 ms |
232432 KB |
Output is correct |
44 |
Execution timed out |
1094 ms |
232432 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |