#include <bits/stdc++.h>
using namespace std;
const int N = 25;
long long n, a, b, ar[N];
long long ans = 1e18;
void calc(long long mask) {
int one = __builtin_popcount(mask) + 1;
if((mask >> (n - 1)) & 1) return;
if(a <= one && one <= b) {
long long sum = 0, temp = 0;
for(int i = 0; i < n; i++) {
sum = sum + ar[i];
if(mask & (1 << i)) {
temp = temp | sum;
sum = 0;
}
}
temp = temp | sum;
if(ans > temp) {
ans = temp;
}
}
}
main() {
cin >> n >> a >> b;
for(int i = 0; i < n; i++) {
cin >> ar[i];
}
for(long long i = 0; i < (1 << n); i++) {
calc(i);
}
cout << ans << endl;
}
Compilation message
sculpture.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
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 |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
252 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
9 ms |
384 KB |
Output is correct |
9 |
Correct |
10 ms |
256 KB |
Output is correct |
10 |
Correct |
8 ms |
256 KB |
Output is correct |
11 |
Correct |
9 ms |
256 KB |
Output is correct |
12 |
Correct |
10 ms |
256 KB |
Output is correct |
13 |
Correct |
48 ms |
360 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
16 ms |
256 KB |
Output is correct |
22 |
Correct |
18 ms |
364 KB |
Output is correct |
23 |
Correct |
12 ms |
256 KB |
Output is correct |
24 |
Correct |
13 ms |
256 KB |
Output is correct |
25 |
Correct |
13 ms |
384 KB |
Output is correct |
26 |
Correct |
46 ms |
384 KB |
Output is correct |
27 |
Correct |
4 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 |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
13 ms |
384 KB |
Output is correct |
32 |
Correct |
10 ms |
128 KB |
Output is correct |
33 |
Correct |
45 ms |
384 KB |
Output is correct |
34 |
Correct |
50 ms |
256 KB |
Output is correct |
35 |
Correct |
7 ms |
384 KB |
Output is correct |
36 |
Correct |
47 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
11 ms |
256 KB |
Output is correct |
9 |
Correct |
10 ms |
384 KB |
Output is correct |
10 |
Correct |
11 ms |
256 KB |
Output is correct |
11 |
Correct |
11 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
61 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
11 ms |
384 KB |
Output is correct |
22 |
Correct |
13 ms |
512 KB |
Output is correct |
23 |
Correct |
12 ms |
384 KB |
Output is correct |
24 |
Correct |
9 ms |
256 KB |
Output is correct |
25 |
Correct |
14 ms |
256 KB |
Output is correct |
26 |
Correct |
52 ms |
388 KB |
Output is correct |
27 |
Correct |
101 ms |
384 KB |
Output is correct |
28 |
Correct |
452 ms |
384 KB |
Output is correct |
29 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
9 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
256 KB |
Output is correct |
10 |
Correct |
11 ms |
256 KB |
Output is correct |
11 |
Correct |
9 ms |
384 KB |
Output is correct |
12 |
Correct |
9 ms |
256 KB |
Output is correct |
13 |
Correct |
48 ms |
256 KB |
Output is correct |
14 |
Correct |
101 ms |
384 KB |
Output is correct |
15 |
Correct |
456 ms |
388 KB |
Output is correct |
16 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
11 ms |
384 KB |
Output is correct |
9 |
Correct |
10 ms |
256 KB |
Output is correct |
10 |
Correct |
9 ms |
384 KB |
Output is correct |
11 |
Correct |
11 ms |
384 KB |
Output is correct |
12 |
Correct |
9 ms |
384 KB |
Output is correct |
13 |
Correct |
53 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
128 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
13 ms |
256 KB |
Output is correct |
22 |
Correct |
17 ms |
256 KB |
Output is correct |
23 |
Correct |
14 ms |
256 KB |
Output is correct |
24 |
Correct |
13 ms |
384 KB |
Output is correct |
25 |
Correct |
11 ms |
256 KB |
Output is correct |
26 |
Correct |
55 ms |
376 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 |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
16 ms |
384 KB |
Output is correct |
32 |
Correct |
12 ms |
384 KB |
Output is correct |
33 |
Correct |
43 ms |
256 KB |
Output is correct |
34 |
Correct |
58 ms |
384 KB |
Output is correct |
35 |
Correct |
10 ms |
384 KB |
Output is correct |
36 |
Correct |
50 ms |
504 KB |
Output is correct |
37 |
Correct |
109 ms |
256 KB |
Output is correct |
38 |
Correct |
426 ms |
352 KB |
Output is correct |
39 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
9 ms |
256 KB |
Output is correct |
9 |
Correct |
13 ms |
384 KB |
Output is correct |
10 |
Correct |
10 ms |
384 KB |
Output is correct |
11 |
Correct |
11 ms |
384 KB |
Output is correct |
12 |
Correct |
14 ms |
256 KB |
Output is correct |
13 |
Correct |
48 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
12 ms |
384 KB |
Output is correct |
19 |
Correct |
11 ms |
384 KB |
Output is correct |
20 |
Correct |
55 ms |
384 KB |
Output is correct |
21 |
Correct |
48 ms |
384 KB |
Output is correct |
22 |
Correct |
9 ms |
256 KB |
Output is correct |
23 |
Correct |
48 ms |
384 KB |
Output is correct |
24 |
Correct |
94 ms |
256 KB |
Output is correct |
25 |
Correct |
513 ms |
356 KB |
Output is correct |
26 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |