#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
unordered_map<ll, ll> dp[110][110];
int a[110], p[110], n;
ll f(int i, int k, ll o) {
if(k > i) return 1e18;
if(k == 1) return p[i] | o;
if(dp[i][k].count(o))
return dp[i][k][o];
ll ret = 1e18;
ll sum = a[i];
for(int j = i - 1; j >= 1; j--) {
ret = min(ret, f(j, k - 1, sum | o) | sum | o);
sum += a[j];
}
return dp[i][k][o] = ret;
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
freopen("in", "r", stdin);
#endif
int n, l, r;
cin >> n >> l >> r;
for(int i = 1; i <= n; i++) {
cin >> a[i]; p[i] = p[i - 1] + a[i];
}
ll ans = 1e18;;
for(int i = l; i <= r; i++) {
ans = min(ans, f(n, i, 0));
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
2 |
Correct |
2 ms |
1120 KB |
Output is correct |
3 |
Correct |
2 ms |
1120 KB |
Output is correct |
4 |
Correct |
2 ms |
1124 KB |
Output is correct |
5 |
Correct |
2 ms |
1196 KB |
Output is correct |
6 |
Correct |
2 ms |
1196 KB |
Output is correct |
7 |
Correct |
2 ms |
1196 KB |
Output is correct |
8 |
Correct |
2 ms |
1240 KB |
Output is correct |
9 |
Correct |
2 ms |
1240 KB |
Output is correct |
10 |
Correct |
2 ms |
1240 KB |
Output is correct |
11 |
Correct |
2 ms |
1240 KB |
Output is correct |
12 |
Correct |
2 ms |
1244 KB |
Output is correct |
13 |
Correct |
3 ms |
1248 KB |
Output is correct |
14 |
Correct |
2 ms |
1248 KB |
Output is correct |
15 |
Correct |
2 ms |
1248 KB |
Output is correct |
16 |
Correct |
2 ms |
1360 KB |
Output is correct |
17 |
Correct |
2 ms |
1360 KB |
Output is correct |
18 |
Correct |
2 ms |
1360 KB |
Output is correct |
19 |
Correct |
2 ms |
1360 KB |
Output is correct |
20 |
Correct |
2 ms |
1360 KB |
Output is correct |
21 |
Correct |
2 ms |
1360 KB |
Output is correct |
22 |
Correct |
3 ms |
1360 KB |
Output is correct |
23 |
Correct |
2 ms |
1360 KB |
Output is correct |
24 |
Correct |
2 ms |
1360 KB |
Output is correct |
25 |
Correct |
2 ms |
1360 KB |
Output is correct |
26 |
Correct |
2 ms |
1360 KB |
Output is correct |
27 |
Incorrect |
2 ms |
1360 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1360 KB |
Output is correct |
2 |
Correct |
3 ms |
1360 KB |
Output is correct |
3 |
Correct |
2 ms |
1360 KB |
Output is correct |
4 |
Correct |
2 ms |
1360 KB |
Output is correct |
5 |
Correct |
2 ms |
1360 KB |
Output is correct |
6 |
Correct |
7 ms |
1360 KB |
Output is correct |
7 |
Correct |
2 ms |
1360 KB |
Output is correct |
8 |
Correct |
2 ms |
1360 KB |
Output is correct |
9 |
Correct |
2 ms |
1360 KB |
Output is correct |
10 |
Correct |
2 ms |
1360 KB |
Output is correct |
11 |
Correct |
2 ms |
1360 KB |
Output is correct |
12 |
Correct |
2 ms |
1360 KB |
Output is correct |
13 |
Correct |
2 ms |
1360 KB |
Output is correct |
14 |
Correct |
2 ms |
1360 KB |
Output is correct |
15 |
Correct |
2 ms |
1360 KB |
Output is correct |
16 |
Correct |
2 ms |
1360 KB |
Output is correct |
17 |
Correct |
2 ms |
1360 KB |
Output is correct |
18 |
Correct |
2 ms |
1360 KB |
Output is correct |
19 |
Correct |
2 ms |
1360 KB |
Output is correct |
20 |
Correct |
2 ms |
1376 KB |
Output is correct |
21 |
Correct |
3 ms |
1376 KB |
Output is correct |
22 |
Correct |
2 ms |
1376 KB |
Output is correct |
23 |
Correct |
2 ms |
1384 KB |
Output is correct |
24 |
Correct |
2 ms |
1384 KB |
Output is correct |
25 |
Correct |
3 ms |
1384 KB |
Output is correct |
26 |
Correct |
2 ms |
1384 KB |
Output is correct |
27 |
Correct |
3 ms |
1384 KB |
Output is correct |
28 |
Correct |
3 ms |
1384 KB |
Output is correct |
29 |
Correct |
2 ms |
1384 KB |
Output is correct |
30 |
Correct |
10 ms |
1644 KB |
Output is correct |
31 |
Correct |
33 ms |
2460 KB |
Output is correct |
32 |
Correct |
27 ms |
2460 KB |
Output is correct |
33 |
Correct |
2 ms |
2460 KB |
Output is correct |
34 |
Correct |
20 ms |
2460 KB |
Output is correct |
35 |
Correct |
26 ms |
2460 KB |
Output is correct |
36 |
Correct |
15 ms |
2460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2460 KB |
Output is correct |
2 |
Correct |
2 ms |
2460 KB |
Output is correct |
3 |
Correct |
2 ms |
2460 KB |
Output is correct |
4 |
Correct |
2 ms |
2460 KB |
Output is correct |
5 |
Correct |
2 ms |
2460 KB |
Output is correct |
6 |
Correct |
2 ms |
2460 KB |
Output is correct |
7 |
Correct |
2 ms |
2460 KB |
Output is correct |
8 |
Correct |
2 ms |
2460 KB |
Output is correct |
9 |
Correct |
2 ms |
2460 KB |
Output is correct |
10 |
Correct |
2 ms |
2460 KB |
Output is correct |
11 |
Correct |
2 ms |
2460 KB |
Output is correct |
12 |
Correct |
2 ms |
2460 KB |
Output is correct |
13 |
Correct |
2 ms |
2460 KB |
Output is correct |
14 |
Correct |
2 ms |
2460 KB |
Output is correct |
15 |
Correct |
3 ms |
2460 KB |
Output is correct |
16 |
Correct |
2 ms |
2460 KB |
Output is correct |
17 |
Correct |
10 ms |
2460 KB |
Output is correct |
18 |
Correct |
32 ms |
2460 KB |
Output is correct |
19 |
Correct |
27 ms |
2460 KB |
Output is correct |
20 |
Correct |
2 ms |
2460 KB |
Output is correct |
21 |
Correct |
21 ms |
2460 KB |
Output is correct |
22 |
Correct |
26 ms |
2460 KB |
Output is correct |
23 |
Correct |
15 ms |
2460 KB |
Output is correct |
24 |
Correct |
29 ms |
2540 KB |
Output is correct |
25 |
Correct |
33 ms |
2540 KB |
Output is correct |
26 |
Correct |
209 ms |
6252 KB |
Output is correct |
27 |
Correct |
678 ms |
14832 KB |
Output is correct |
28 |
Execution timed out |
1058 ms |
19832 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
19832 KB |
Output is correct |
2 |
Correct |
2 ms |
19832 KB |
Output is correct |
3 |
Correct |
2 ms |
19832 KB |
Output is correct |
4 |
Correct |
2 ms |
19832 KB |
Output is correct |
5 |
Correct |
2 ms |
19832 KB |
Output is correct |
6 |
Correct |
2 ms |
19832 KB |
Output is correct |
7 |
Correct |
2 ms |
19832 KB |
Output is correct |
8 |
Correct |
2 ms |
19832 KB |
Output is correct |
9 |
Correct |
2 ms |
19832 KB |
Output is correct |
10 |
Correct |
2 ms |
19832 KB |
Output is correct |
11 |
Correct |
2 ms |
19832 KB |
Output is correct |
12 |
Correct |
2 ms |
19832 KB |
Output is correct |
13 |
Correct |
3 ms |
19832 KB |
Output is correct |
14 |
Correct |
2 ms |
19832 KB |
Output is correct |
15 |
Correct |
2 ms |
19832 KB |
Output is correct |
16 |
Correct |
2 ms |
19832 KB |
Output is correct |
17 |
Correct |
2 ms |
19832 KB |
Output is correct |
18 |
Correct |
2 ms |
19832 KB |
Output is correct |
19 |
Correct |
2 ms |
19832 KB |
Output is correct |
20 |
Correct |
2 ms |
19832 KB |
Output is correct |
21 |
Correct |
2 ms |
19832 KB |
Output is correct |
22 |
Correct |
2 ms |
19832 KB |
Output is correct |
23 |
Correct |
2 ms |
19832 KB |
Output is correct |
24 |
Correct |
2 ms |
19832 KB |
Output is correct |
25 |
Correct |
2 ms |
19832 KB |
Output is correct |
26 |
Correct |
2 ms |
19832 KB |
Output is correct |
27 |
Incorrect |
2 ms |
19832 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
19832 KB |
Output is correct |
2 |
Correct |
2 ms |
19832 KB |
Output is correct |
3 |
Correct |
3 ms |
19832 KB |
Output is correct |
4 |
Correct |
2 ms |
19832 KB |
Output is correct |
5 |
Correct |
2 ms |
19832 KB |
Output is correct |
6 |
Correct |
3 ms |
19832 KB |
Output is correct |
7 |
Correct |
2 ms |
19832 KB |
Output is correct |
8 |
Correct |
2 ms |
19832 KB |
Output is correct |
9 |
Correct |
2 ms |
19832 KB |
Output is correct |
10 |
Correct |
2 ms |
19832 KB |
Output is correct |
11 |
Correct |
2 ms |
19832 KB |
Output is correct |
12 |
Correct |
2 ms |
19832 KB |
Output is correct |
13 |
Correct |
2 ms |
19832 KB |
Output is correct |
14 |
Incorrect |
2 ms |
19832 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |