#include <bits/stdc++.h>
using namespace std;
const int N = 25;
int n, a, b, ar[N];
long long ans = 1000000000000000000LL;
int count(int mask) {
int res = 0;
while(mask) {
res += ((mask & 1) != 0);
mask >>= 1;
}
return res;
}
void calc(int mask) {
int one = count(mask) + 1;
if(a <= one && one <= b) {
int 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(int i = 0; i < (1 << n); i++) {
calc(i);
}
cout << ans << endl;
}
Compilation message
sculpture.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
356 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
21 ms |
384 KB |
Output is correct |
9 |
Correct |
26 ms |
376 KB |
Output is correct |
10 |
Correct |
19 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
384 KB |
Output is correct |
12 |
Correct |
30 ms |
256 KB |
Output is correct |
13 |
Correct |
125 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
29 ms |
384 KB |
Output is correct |
9 |
Correct |
20 ms |
256 KB |
Output is correct |
10 |
Correct |
36 ms |
256 KB |
Output is correct |
11 |
Correct |
24 ms |
392 KB |
Output is correct |
12 |
Correct |
20 ms |
400 KB |
Output is correct |
13 |
Correct |
97 ms |
360 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 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 |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
22 ms |
256 KB |
Output is correct |
9 |
Correct |
24 ms |
300 KB |
Output is correct |
10 |
Correct |
22 ms |
256 KB |
Output is correct |
11 |
Correct |
23 ms |
284 KB |
Output is correct |
12 |
Correct |
22 ms |
256 KB |
Output is correct |
13 |
Correct |
106 ms |
256 KB |
Output is correct |
14 |
Correct |
197 ms |
384 KB |
Output is correct |
15 |
Execution timed out |
1030 ms |
256 KB |
Time limit exceeded |
16 |
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 |
2 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 |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
22 ms |
384 KB |
Output is correct |
9 |
Correct |
24 ms |
384 KB |
Output is correct |
10 |
Correct |
23 ms |
384 KB |
Output is correct |
11 |
Correct |
22 ms |
384 KB |
Output is correct |
12 |
Correct |
21 ms |
384 KB |
Output is correct |
13 |
Correct |
105 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
256 KB |
Output is correct |
15 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
276 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
24 ms |
384 KB |
Output is correct |
9 |
Correct |
24 ms |
372 KB |
Output is correct |
10 |
Correct |
21 ms |
256 KB |
Output is correct |
11 |
Correct |
24 ms |
256 KB |
Output is correct |
12 |
Correct |
30 ms |
384 KB |
Output is correct |
13 |
Correct |
96 ms |
384 KB |
Output is correct |
14 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |