#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll>
#define pii pair <int, int>
#define triple pair <pair <ll, ll> , ll>
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>
const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 2e3 + 5;
const ll shift = 2e6;
const ll mod = 998244353;
const ll mod2 = 1e9 + 9;
const ll M = 1e3 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll sp2 = 9973;
const int block = 100;
const double eps = 1e-10;
ll n, a, b, Y[N], ans = INF, pref[N];
int main(){
speed;
cin >> n >> a >> b;
for(int i = 1; i <= n; i++){
cin >> Y[i];
pref[i] = pref[i - 1] + Y[i];
}
for(ll col = a; col <= b; col++){
for(ll mask = 0; mask < (1 << (n - 1)); mask++){
if(__builtin_popcount(mask) != (col - 1))
continue;
// cout << "FOUND " << mask << endl;
ll last = 0, cur = 0;
for(int i = 0; i < n; i++){
if((1 << i) & mask){
cur = (cur | (pref[i + 1] - pref[last]));
last = i + 1;
}
}
cur = (cur | (pref[n] - pref[last]));
ans = min(ans, cur);
}
}
cout << ans << endl;
}
/*
%I64d6
6 1 3
8 1 2 1 5 4
5 5 5
1 2 3 4 5
%I64d
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
4 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
320 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
324 KB |
Output is correct |
13 |
Correct |
54 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
320 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
320 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
9 ms |
324 KB |
Output is correct |
22 |
Correct |
8 ms |
212 KB |
Output is correct |
23 |
Correct |
12 ms |
212 KB |
Output is correct |
24 |
Correct |
2 ms |
212 KB |
Output is correct |
25 |
Correct |
12 ms |
328 KB |
Output is correct |
26 |
Correct |
41 ms |
316 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
328 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
14 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
212 KB |
Output is correct |
33 |
Correct |
50 ms |
308 KB |
Output is correct |
34 |
Correct |
60 ms |
212 KB |
Output is correct |
35 |
Correct |
5 ms |
212 KB |
Output is correct |
36 |
Correct |
63 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
5 ms |
324 KB |
Output is correct |
10 |
Correct |
5 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
5 ms |
212 KB |
Output is correct |
13 |
Correct |
53 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
320 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
9 ms |
212 KB |
Output is correct |
22 |
Correct |
8 ms |
328 KB |
Output is correct |
23 |
Correct |
9 ms |
320 KB |
Output is correct |
24 |
Correct |
2 ms |
212 KB |
Output is correct |
25 |
Correct |
11 ms |
212 KB |
Output is correct |
26 |
Correct |
42 ms |
320 KB |
Output is correct |
27 |
Correct |
119 ms |
324 KB |
Output is correct |
28 |
Correct |
591 ms |
304 KB |
Output is correct |
29 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
332 KB |
Output is correct |
9 |
Correct |
4 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
324 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
55 ms |
320 KB |
Output is correct |
14 |
Correct |
115 ms |
212 KB |
Output is correct |
15 |
Correct |
568 ms |
212 KB |
Output is correct |
16 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
9 ms |
212 KB |
Output is correct |
10 |
Correct |
7 ms |
328 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
57 ms |
304 KB |
Output is correct |
14 |
Correct |
0 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
320 KB |
Output is correct |
21 |
Correct |
10 ms |
212 KB |
Output is correct |
22 |
Correct |
9 ms |
320 KB |
Output is correct |
23 |
Correct |
8 ms |
212 KB |
Output is correct |
24 |
Correct |
2 ms |
212 KB |
Output is correct |
25 |
Correct |
11 ms |
328 KB |
Output is correct |
26 |
Correct |
41 ms |
324 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
288 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
13 ms |
336 KB |
Output is correct |
32 |
Correct |
2 ms |
212 KB |
Output is correct |
33 |
Correct |
51 ms |
308 KB |
Output is correct |
34 |
Correct |
59 ms |
304 KB |
Output is correct |
35 |
Correct |
5 ms |
324 KB |
Output is correct |
36 |
Correct |
67 ms |
312 KB |
Output is correct |
37 |
Correct |
119 ms |
212 KB |
Output is correct |
38 |
Correct |
568 ms |
308 KB |
Output is correct |
39 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
3 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
4 ms |
340 KB |
Output is correct |
9 |
Correct |
5 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
324 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
4 ms |
328 KB |
Output is correct |
13 |
Correct |
55 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
328 KB |
Output is correct |
18 |
Correct |
13 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
45 ms |
320 KB |
Output is correct |
21 |
Correct |
58 ms |
308 KB |
Output is correct |
22 |
Correct |
4 ms |
212 KB |
Output is correct |
23 |
Correct |
60 ms |
324 KB |
Output is correct |
24 |
Correct |
117 ms |
328 KB |
Output is correct |
25 |
Correct |
570 ms |
312 KB |
Output is correct |
26 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |