#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e15;
const int nax = 2000;
int a, b, n;
int y[nax+5];
ll f(int idx, ll sum, ll val, int grup) {
if(idx==n) return (a <= grup && grup <= b) ? (val | (sum + y[n])) : INF;
return min(f(idx+1, sum+y[idx], val, grup), f(idx+1, 0, val | (sum+y[idx]), grup+1));
}
int main() {
scanf("%d %d %d", &n, &a, &b);
for(int i=1; i<=n; i++) {
scanf("%d", &y[i]);
}
printf("%lld", f(1, 0, 0, 1));
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d %d %d", &n, &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d", &y[i]);
| ~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
204 KB |
Output is correct |
12 |
Correct |
3 ms |
292 KB |
Output is correct |
13 |
Correct |
5 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
292 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
4 ms |
204 KB |
Output is correct |
22 |
Correct |
4 ms |
204 KB |
Output is correct |
23 |
Correct |
3 ms |
204 KB |
Output is correct |
24 |
Correct |
4 ms |
296 KB |
Output is correct |
25 |
Correct |
4 ms |
204 KB |
Output is correct |
26 |
Correct |
4 ms |
204 KB |
Output is correct |
27 |
Correct |
0 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
292 KB |
Output is correct |
30 |
Correct |
2 ms |
208 KB |
Output is correct |
31 |
Correct |
5 ms |
204 KB |
Output is correct |
32 |
Correct |
4 ms |
204 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
4 ms |
204 KB |
Output is correct |
35 |
Correct |
4 ms |
204 KB |
Output is correct |
36 |
Correct |
4 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
280 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
7 ms |
284 KB |
Output is correct |
11 |
Correct |
4 ms |
296 KB |
Output is correct |
12 |
Correct |
5 ms |
204 KB |
Output is correct |
13 |
Correct |
3 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
292 KB |
Output is correct |
15 |
Correct |
0 ms |
284 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
3 ms |
204 KB |
Output is correct |
22 |
Correct |
3 ms |
204 KB |
Output is correct |
23 |
Correct |
4 ms |
296 KB |
Output is correct |
24 |
Correct |
4 ms |
204 KB |
Output is correct |
25 |
Correct |
5 ms |
204 KB |
Output is correct |
26 |
Correct |
4 ms |
296 KB |
Output is correct |
27 |
Correct |
7 ms |
204 KB |
Output is correct |
28 |
Correct |
92 ms |
284 KB |
Output is correct |
29 |
Execution timed out |
1082 ms |
248 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
296 KB |
Output is correct |
9 |
Correct |
3 ms |
216 KB |
Output is correct |
10 |
Correct |
4 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
204 KB |
Output is correct |
12 |
Correct |
3 ms |
296 KB |
Output is correct |
13 |
Correct |
6 ms |
204 KB |
Output is correct |
14 |
Correct |
7 ms |
204 KB |
Output is correct |
15 |
Correct |
90 ms |
272 KB |
Output is correct |
16 |
Execution timed out |
1066 ms |
204 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
4 ms |
296 KB |
Output is correct |
10 |
Correct |
3 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
204 KB |
Output is correct |
12 |
Correct |
4 ms |
292 KB |
Output is correct |
13 |
Correct |
3 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
296 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
3 ms |
204 KB |
Output is correct |
22 |
Correct |
3 ms |
204 KB |
Output is correct |
23 |
Correct |
3 ms |
204 KB |
Output is correct |
24 |
Correct |
4 ms |
204 KB |
Output is correct |
25 |
Correct |
3 ms |
292 KB |
Output is correct |
26 |
Correct |
3 ms |
204 KB |
Output is correct |
27 |
Correct |
0 ms |
204 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
0 ms |
208 KB |
Output is correct |
30 |
Correct |
2 ms |
208 KB |
Output is correct |
31 |
Correct |
3 ms |
204 KB |
Output is correct |
32 |
Correct |
3 ms |
204 KB |
Output is correct |
33 |
Correct |
5 ms |
204 KB |
Output is correct |
34 |
Correct |
3 ms |
204 KB |
Output is correct |
35 |
Correct |
3 ms |
296 KB |
Output is correct |
36 |
Correct |
3 ms |
300 KB |
Output is correct |
37 |
Correct |
6 ms |
296 KB |
Output is correct |
38 |
Correct |
90 ms |
276 KB |
Output is correct |
39 |
Execution timed out |
1080 ms |
204 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
244 KB |
Output is correct |
9 |
Correct |
3 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
204 KB |
Output is correct |
12 |
Correct |
3 ms |
204 KB |
Output is correct |
13 |
Correct |
3 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
3 ms |
292 KB |
Output is correct |
18 |
Correct |
4 ms |
204 KB |
Output is correct |
19 |
Correct |
4 ms |
292 KB |
Output is correct |
20 |
Correct |
5 ms |
292 KB |
Output is correct |
21 |
Correct |
3 ms |
204 KB |
Output is correct |
22 |
Correct |
4 ms |
272 KB |
Output is correct |
23 |
Correct |
3 ms |
204 KB |
Output is correct |
24 |
Correct |
6 ms |
204 KB |
Output is correct |
25 |
Correct |
100 ms |
280 KB |
Output is correct |
26 |
Execution timed out |
1089 ms |
204 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |