#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000LL * 2001LL;
int n, a, b;
ll arr[2001];
ll dp[2001][2001];
ll solve(int pos, int cnt) {
if (pos == n) {
if (a <= cnt && cnt <= b) return 0;
else return INF;
}
ll& ret = dp[pos][cnt];
if (ret != -1) return ret;
ret = INF;
ll sum = 0;
for (int i = pos; i <= n; i++) {
sum += arr[i];
ret = min(ret, solve(i+1, cnt+1)|sum);
}
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> a >> b;
for (int i = 0; i < n; i++) cin >> arr[i];
memset(dp, -1, sizeof(dp));
cout << solve(0, 0);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
31724 KB |
Output is correct |
2 |
Correct |
17 ms |
31724 KB |
Output is correct |
3 |
Correct |
17 ms |
31724 KB |
Output is correct |
4 |
Correct |
18 ms |
31724 KB |
Output is correct |
5 |
Correct |
17 ms |
31724 KB |
Output is correct |
6 |
Correct |
17 ms |
31724 KB |
Output is correct |
7 |
Correct |
17 ms |
31724 KB |
Output is correct |
8 |
Correct |
17 ms |
31724 KB |
Output is correct |
9 |
Correct |
17 ms |
31724 KB |
Output is correct |
10 |
Correct |
17 ms |
31724 KB |
Output is correct |
11 |
Correct |
18 ms |
31724 KB |
Output is correct |
12 |
Correct |
17 ms |
31724 KB |
Output is correct |
13 |
Correct |
17 ms |
31724 KB |
Output is correct |
14 |
Correct |
17 ms |
31724 KB |
Output is correct |
15 |
Correct |
17 ms |
31724 KB |
Output is correct |
16 |
Correct |
17 ms |
31724 KB |
Output is correct |
17 |
Correct |
17 ms |
31724 KB |
Output is correct |
18 |
Correct |
18 ms |
31724 KB |
Output is correct |
19 |
Correct |
17 ms |
31724 KB |
Output is correct |
20 |
Correct |
17 ms |
31724 KB |
Output is correct |
21 |
Incorrect |
17 ms |
31724 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
31724 KB |
Output is correct |
2 |
Correct |
17 ms |
31724 KB |
Output is correct |
3 |
Correct |
17 ms |
31724 KB |
Output is correct |
4 |
Correct |
17 ms |
31744 KB |
Output is correct |
5 |
Correct |
17 ms |
31724 KB |
Output is correct |
6 |
Correct |
17 ms |
31724 KB |
Output is correct |
7 |
Correct |
17 ms |
31724 KB |
Output is correct |
8 |
Correct |
17 ms |
31724 KB |
Output is correct |
9 |
Correct |
17 ms |
31724 KB |
Output is correct |
10 |
Correct |
17 ms |
31724 KB |
Output is correct |
11 |
Correct |
17 ms |
31724 KB |
Output is correct |
12 |
Correct |
17 ms |
31724 KB |
Output is correct |
13 |
Correct |
18 ms |
31724 KB |
Output is correct |
14 |
Correct |
19 ms |
31724 KB |
Output is correct |
15 |
Correct |
17 ms |
31724 KB |
Output is correct |
16 |
Correct |
17 ms |
31724 KB |
Output is correct |
17 |
Correct |
17 ms |
31724 KB |
Output is correct |
18 |
Correct |
17 ms |
31724 KB |
Output is correct |
19 |
Correct |
17 ms |
31724 KB |
Output is correct |
20 |
Correct |
17 ms |
31724 KB |
Output is correct |
21 |
Incorrect |
17 ms |
31724 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
31724 KB |
Output is correct |
2 |
Correct |
17 ms |
31724 KB |
Output is correct |
3 |
Correct |
17 ms |
31724 KB |
Output is correct |
4 |
Correct |
17 ms |
31724 KB |
Output is correct |
5 |
Correct |
18 ms |
31724 KB |
Output is correct |
6 |
Correct |
18 ms |
31724 KB |
Output is correct |
7 |
Correct |
17 ms |
31724 KB |
Output is correct |
8 |
Correct |
17 ms |
31724 KB |
Output is correct |
9 |
Correct |
18 ms |
31724 KB |
Output is correct |
10 |
Correct |
16 ms |
31724 KB |
Output is correct |
11 |
Correct |
16 ms |
31724 KB |
Output is correct |
12 |
Correct |
16 ms |
31724 KB |
Output is correct |
13 |
Correct |
17 ms |
31724 KB |
Output is correct |
14 |
Correct |
19 ms |
31724 KB |
Output is correct |
15 |
Correct |
19 ms |
31724 KB |
Output is correct |
16 |
Correct |
16 ms |
31724 KB |
Output is correct |
17 |
Correct |
16 ms |
31724 KB |
Output is correct |
18 |
Correct |
21 ms |
31724 KB |
Output is correct |
19 |
Correct |
16 ms |
31724 KB |
Output is correct |
20 |
Correct |
16 ms |
31724 KB |
Output is correct |
21 |
Correct |
24 ms |
31724 KB |
Output is correct |
22 |
Correct |
16 ms |
31724 KB |
Output is correct |
23 |
Correct |
17 ms |
31724 KB |
Output is correct |
24 |
Correct |
18 ms |
31724 KB |
Output is correct |
25 |
Correct |
22 ms |
31724 KB |
Output is correct |
26 |
Correct |
17 ms |
31724 KB |
Output is correct |
27 |
Correct |
17 ms |
31724 KB |
Output is correct |
28 |
Correct |
17 ms |
31724 KB |
Output is correct |
29 |
Correct |
17 ms |
31724 KB |
Output is correct |
30 |
Correct |
17 ms |
31724 KB |
Output is correct |
31 |
Correct |
17 ms |
31724 KB |
Output is correct |
32 |
Correct |
17 ms |
31724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
31724 KB |
Output is correct |
2 |
Correct |
17 ms |
31724 KB |
Output is correct |
3 |
Correct |
17 ms |
31724 KB |
Output is correct |
4 |
Correct |
17 ms |
31724 KB |
Output is correct |
5 |
Correct |
17 ms |
31684 KB |
Output is correct |
6 |
Correct |
18 ms |
31724 KB |
Output is correct |
7 |
Correct |
20 ms |
31724 KB |
Output is correct |
8 |
Correct |
18 ms |
31724 KB |
Output is correct |
9 |
Correct |
16 ms |
31724 KB |
Output is correct |
10 |
Correct |
16 ms |
31724 KB |
Output is correct |
11 |
Correct |
16 ms |
31724 KB |
Output is correct |
12 |
Correct |
17 ms |
31724 KB |
Output is correct |
13 |
Correct |
17 ms |
31724 KB |
Output is correct |
14 |
Correct |
16 ms |
31724 KB |
Output is correct |
15 |
Correct |
16 ms |
31724 KB |
Output is correct |
16 |
Correct |
16 ms |
31724 KB |
Output is correct |
17 |
Correct |
20 ms |
31724 KB |
Output is correct |
18 |
Correct |
20 ms |
31724 KB |
Output is correct |
19 |
Correct |
16 ms |
31724 KB |
Output is correct |
20 |
Correct |
16 ms |
31724 KB |
Output is correct |
21 |
Incorrect |
16 ms |
31724 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
31724 KB |
Output is correct |
2 |
Correct |
17 ms |
31744 KB |
Output is correct |
3 |
Correct |
19 ms |
31724 KB |
Output is correct |
4 |
Correct |
17 ms |
31724 KB |
Output is correct |
5 |
Correct |
17 ms |
31724 KB |
Output is correct |
6 |
Correct |
17 ms |
31724 KB |
Output is correct |
7 |
Correct |
17 ms |
31724 KB |
Output is correct |
8 |
Correct |
17 ms |
31724 KB |
Output is correct |
9 |
Correct |
17 ms |
31724 KB |
Output is correct |
10 |
Correct |
19 ms |
31724 KB |
Output is correct |
11 |
Correct |
17 ms |
31724 KB |
Output is correct |
12 |
Correct |
17 ms |
31724 KB |
Output is correct |
13 |
Correct |
17 ms |
31724 KB |
Output is correct |
14 |
Correct |
21 ms |
31724 KB |
Output is correct |
15 |
Correct |
18 ms |
31724 KB |
Output is correct |
16 |
Correct |
17 ms |
31724 KB |
Output is correct |
17 |
Correct |
19 ms |
31744 KB |
Output is correct |
18 |
Incorrect |
18 ms |
31744 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |