#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 21, inf = 1e15;
int n, a, b, ans = inf, ar[N];
void calc(int mask) {
int one = __builtin_popcount(mask) + 1;
if(a <= one && one <= b) {
int sum = 0, temp = 0;
for(int i = 0; i < n; i++) {
sum += ar[i];
if(mask >> i & 1) {
temp |= sum;
sum = 0;
}
}
temp |= sum;
if(ans > temp) {
ans = temp;
}
}
}
main() {
cin >> n >> a >> b;
for(int i = 0; i < n; i++) {
cin >> ar[i];
}
for(int 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() {
^
# |
결과 |
실행 시간 |
메모리 |
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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
8 ms |
256 KB |
Output is correct |
9 |
Correct |
8 ms |
256 KB |
Output is correct |
10 |
Correct |
10 ms |
256 KB |
Output is correct |
11 |
Correct |
9 ms |
384 KB |
Output is correct |
12 |
Correct |
8 ms |
384 KB |
Output is correct |
13 |
Correct |
78 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
10 ms |
256 KB |
Output is correct |
9 |
Correct |
9 ms |
384 KB |
Output is correct |
10 |
Correct |
8 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
256 KB |
Output is correct |
12 |
Correct |
8 ms |
256 KB |
Output is correct |
13 |
Correct |
87 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
128 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
8 ms |
384 KB |
Output is correct |
9 |
Correct |
8 ms |
384 KB |
Output is correct |
10 |
Correct |
9 ms |
384 KB |
Output is correct |
11 |
Correct |
9 ms |
384 KB |
Output is correct |
12 |
Correct |
9 ms |
384 KB |
Output is correct |
13 |
Correct |
81 ms |
384 KB |
Output is correct |
14 |
Correct |
153 ms |
504 KB |
Output is correct |
15 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
8 ms |
256 KB |
Output is correct |
9 |
Correct |
11 ms |
384 KB |
Output is correct |
10 |
Correct |
12 ms |
256 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
9 ms |
384 KB |
Output is correct |
13 |
Correct |
75 ms |
388 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 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 |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
9 ms |
384 KB |
Output is correct |
9 |
Correct |
8 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
256 KB |
Output is correct |
11 |
Correct |
10 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
73 ms |
356 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
7 ms |
384 KB |
Output is correct |
18 |
Correct |
11 ms |
256 KB |
Output is correct |
19 |
Correct |
9 ms |
368 KB |
Output is correct |
20 |
Correct |
69 ms |
256 KB |
Output is correct |
21 |
Correct |
83 ms |
384 KB |
Output is correct |
22 |
Correct |
8 ms |
384 KB |
Output is correct |
23 |
Correct |
85 ms |
504 KB |
Output is correct |
24 |
Correct |
157 ms |
388 KB |
Output is correct |
25 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |