#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
#define ll long long
ll a[N];
int main () {
// freopen ("input.txt", "r", stdin);
ll n, A, B;
cin >> n >> A >> B;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
ll jogap = 2e18;
for (int i = 0; i < (1 << n); ++i) {
int x = __builtin_popcount(i);
if (x < A or x > B) continue;
ll jog = 0;
ll el = 0, sum = 0;
for (int j = 0; j < n; ++j) {
sum += a[j];
el++;
if (i>>j&1) {
jog |= sum;
sum = el = 0;
}
}
if (!el) {
jogap = min (jogap, jog);
}
}
cout << jogap;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
3 ms |
440 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
65 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
10 ms |
348 KB |
Output is correct |
22 |
Correct |
10 ms |
436 KB |
Output is correct |
23 |
Correct |
10 ms |
444 KB |
Output is correct |
24 |
Correct |
3 ms |
348 KB |
Output is correct |
25 |
Correct |
10 ms |
348 KB |
Output is correct |
26 |
Correct |
59 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
600 KB |
Output is correct |
30 |
Correct |
1 ms |
440 KB |
Output is correct |
31 |
Correct |
10 ms |
348 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
60 ms |
348 KB |
Output is correct |
34 |
Correct |
64 ms |
412 KB |
Output is correct |
35 |
Correct |
3 ms |
356 KB |
Output is correct |
36 |
Correct |
70 ms |
416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
448 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
65 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
10 ms |
444 KB |
Output is correct |
22 |
Correct |
10 ms |
344 KB |
Output is correct |
23 |
Correct |
10 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
12 ms |
436 KB |
Output is correct |
26 |
Correct |
59 ms |
344 KB |
Output is correct |
27 |
Correct |
131 ms |
344 KB |
Output is correct |
28 |
Correct |
515 ms |
416 KB |
Output is correct |
29 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
436 KB |
Output is correct |
11 |
Correct |
2 ms |
356 KB |
Output is correct |
12 |
Correct |
3 ms |
440 KB |
Output is correct |
13 |
Correct |
65 ms |
416 KB |
Output is correct |
14 |
Correct |
130 ms |
412 KB |
Output is correct |
15 |
Correct |
516 ms |
416 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
436 KB |
Output is correct |
8 |
Correct |
3 ms |
440 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
436 KB |
Output is correct |
13 |
Correct |
66 ms |
420 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
11 ms |
348 KB |
Output is correct |
22 |
Correct |
10 ms |
436 KB |
Output is correct |
23 |
Correct |
10 ms |
348 KB |
Output is correct |
24 |
Correct |
3 ms |
348 KB |
Output is correct |
25 |
Correct |
10 ms |
348 KB |
Output is correct |
26 |
Correct |
59 ms |
416 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
10 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
60 ms |
416 KB |
Output is correct |
34 |
Correct |
64 ms |
348 KB |
Output is correct |
35 |
Correct |
2 ms |
348 KB |
Output is correct |
36 |
Correct |
65 ms |
412 KB |
Output is correct |
37 |
Correct |
130 ms |
348 KB |
Output is correct |
38 |
Correct |
515 ms |
420 KB |
Output is correct |
39 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
352 KB |
Output is correct |
5 |
Correct |
0 ms |
532 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
600 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
436 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
64 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
600 KB |
Output is correct |
18 |
Correct |
10 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
67 ms |
348 KB |
Output is correct |
21 |
Correct |
64 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
64 ms |
348 KB |
Output is correct |
24 |
Correct |
138 ms |
420 KB |
Output is correct |
25 |
Correct |
509 ms |
416 KB |
Output is correct |
26 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |