#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2001;
int dp[N];
int s[N], A[N];
vector<int> vals[N][2];
int32_t main(){
int n, a, b;
cin >> n >> a >> b;
vals[0][0].push_back(0);
for(int i = 1; i <= n; i++) cin >> A[i], s[i] = s[i - 1] + A[i];
int ans = (1LL << 60);
for(int k = 1; k <= n; k++){
for(int i = k; i <= n; i++){
vals[i][k % 2].clear();
for(int j = 0; j < i; j++){
for(auto v : vals[j][(k + 1) % 2]){
vals[i][k % 2].push_back(v | (s[i] - s[j]));
}
}
sort(vals[i][k % 2].begin(), vals[i][k % 2].end());
vals[i][k % 2].resize(unique(vals[i][k % 2].begin(), vals[i][k % 2].end()) - vals[i][k % 2].begin());
}
if(k >= a && k <= b){
ans = min(ans, vals[n][k % 2].front());
}
// for(auto j : vals[i]) cout << j << ' '; cout << endl;
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
396 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
396 KB |
Output is correct |
8 |
Correct |
1 ms |
400 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Incorrect |
1 ms |
396 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
392 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Incorrect |
1 ms |
396 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
396 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
400 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
396 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
396 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
3 ms |
468 KB |
Output is correct |
16 |
Correct |
12 ms |
780 KB |
Output is correct |
17 |
Correct |
17 ms |
724 KB |
Output is correct |
18 |
Correct |
58 ms |
1492 KB |
Output is correct |
19 |
Correct |
33 ms |
1008 KB |
Output is correct |
20 |
Correct |
30 ms |
980 KB |
Output is correct |
21 |
Correct |
30 ms |
980 KB |
Output is correct |
22 |
Correct |
32 ms |
980 KB |
Output is correct |
23 |
Correct |
37 ms |
1192 KB |
Output is correct |
24 |
Correct |
55 ms |
1364 KB |
Output is correct |
25 |
Correct |
181 ms |
2812 KB |
Output is correct |
26 |
Correct |
390 ms |
4812 KB |
Output is correct |
27 |
Correct |
684 ms |
6760 KB |
Output is correct |
28 |
Correct |
979 ms |
8652 KB |
Output is correct |
29 |
Correct |
654 ms |
6260 KB |
Output is correct |
30 |
Correct |
689 ms |
6384 KB |
Output is correct |
31 |
Execution timed out |
1084 ms |
10020 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
400 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
392 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
400 KB |
Output is correct |
15 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
396 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
400 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
6 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
396 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
12 ms |
788 KB |
Output is correct |
27 |
Correct |
16 ms |
724 KB |
Output is correct |
28 |
Correct |
53 ms |
1600 KB |
Output is correct |
29 |
Correct |
36 ms |
980 KB |
Output is correct |
30 |
Correct |
32 ms |
1032 KB |
Output is correct |
31 |
Correct |
34 ms |
980 KB |
Output is correct |
32 |
Correct |
43 ms |
1056 KB |
Output is correct |
33 |
Correct |
44 ms |
1108 KB |
Output is correct |
34 |
Correct |
62 ms |
1476 KB |
Output is correct |
35 |
Correct |
168 ms |
2800 KB |
Output is correct |
36 |
Correct |
398 ms |
4812 KB |
Output is correct |
37 |
Correct |
646 ms |
6604 KB |
Output is correct |
38 |
Correct |
993 ms |
8616 KB |
Output is correct |
39 |
Correct |
615 ms |
6240 KB |
Output is correct |
40 |
Correct |
637 ms |
6264 KB |
Output is correct |
41 |
Execution timed out |
1065 ms |
10056 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |