#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
unordered_map<int, ll> dp[110][110];
int a[110], p[110], n;
ll f(int i, int k, int 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;
int 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 |
1188 KB |
Output is correct |
5 |
Correct |
2 ms |
1188 KB |
Output is correct |
6 |
Correct |
2 ms |
1200 KB |
Output is correct |
7 |
Correct |
2 ms |
1216 KB |
Output is correct |
8 |
Correct |
2 ms |
1216 KB |
Output is correct |
9 |
Correct |
2 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
1216 KB |
Output is correct |
11 |
Correct |
2 ms |
1216 KB |
Output is correct |
12 |
Correct |
2 ms |
1328 KB |
Output is correct |
13 |
Correct |
2 ms |
1328 KB |
Output is correct |
14 |
Correct |
2 ms |
1328 KB |
Output is correct |
15 |
Correct |
2 ms |
1328 KB |
Output is correct |
16 |
Correct |
2 ms |
1328 KB |
Output is correct |
17 |
Correct |
2 ms |
1328 KB |
Output is correct |
18 |
Correct |
2 ms |
1328 KB |
Output is correct |
19 |
Correct |
2 ms |
1328 KB |
Output is correct |
20 |
Correct |
2 ms |
1328 KB |
Output is correct |
21 |
Correct |
2 ms |
1328 KB |
Output is correct |
22 |
Correct |
2 ms |
1328 KB |
Output is correct |
23 |
Correct |
2 ms |
1328 KB |
Output is correct |
24 |
Correct |
2 ms |
1328 KB |
Output is correct |
25 |
Correct |
2 ms |
1328 KB |
Output is correct |
26 |
Correct |
2 ms |
1328 KB |
Output is correct |
27 |
Incorrect |
2 ms |
1328 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1328 KB |
Output is correct |
2 |
Correct |
2 ms |
1328 KB |
Output is correct |
3 |
Correct |
2 ms |
1328 KB |
Output is correct |
4 |
Correct |
2 ms |
1328 KB |
Output is correct |
5 |
Correct |
2 ms |
1328 KB |
Output is correct |
6 |
Correct |
2 ms |
1328 KB |
Output is correct |
7 |
Correct |
2 ms |
1328 KB |
Output is correct |
8 |
Correct |
2 ms |
1372 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
3 ms |
1372 KB |
Output is correct |
14 |
Correct |
2 ms |
1372 KB |
Output is correct |
15 |
Correct |
2 ms |
1372 KB |
Output is correct |
16 |
Correct |
2 ms |
1372 KB |
Output is correct |
17 |
Correct |
2 ms |
1372 KB |
Output is correct |
18 |
Correct |
2 ms |
1372 KB |
Output is correct |
19 |
Correct |
2 ms |
1372 KB |
Output is correct |
20 |
Correct |
2 ms |
1372 KB |
Output is correct |
21 |
Correct |
2 ms |
1372 KB |
Output is correct |
22 |
Correct |
2 ms |
1372 KB |
Output is correct |
23 |
Correct |
3 ms |
1372 KB |
Output is correct |
24 |
Correct |
2 ms |
1372 KB |
Output is correct |
25 |
Correct |
2 ms |
1372 KB |
Output is correct |
26 |
Correct |
2 ms |
1372 KB |
Output is correct |
27 |
Correct |
3 ms |
1372 KB |
Output is correct |
28 |
Correct |
3 ms |
1372 KB |
Output is correct |
29 |
Correct |
2 ms |
1372 KB |
Output is correct |
30 |
Correct |
12 ms |
1644 KB |
Output is correct |
31 |
Correct |
35 ms |
2412 KB |
Output is correct |
32 |
Correct |
24 ms |
2412 KB |
Output is correct |
33 |
Correct |
2 ms |
2412 KB |
Output is correct |
34 |
Correct |
22 ms |
2412 KB |
Output is correct |
35 |
Correct |
26 ms |
2412 KB |
Output is correct |
36 |
Correct |
10 ms |
2412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2412 KB |
Output is correct |
2 |
Correct |
3 ms |
2412 KB |
Output is correct |
3 |
Correct |
2 ms |
2412 KB |
Output is correct |
4 |
Correct |
2 ms |
2412 KB |
Output is correct |
5 |
Correct |
2 ms |
2412 KB |
Output is correct |
6 |
Correct |
2 ms |
2412 KB |
Output is correct |
7 |
Correct |
2 ms |
2412 KB |
Output is correct |
8 |
Correct |
2 ms |
2412 KB |
Output is correct |
9 |
Correct |
2 ms |
2412 KB |
Output is correct |
10 |
Correct |
2 ms |
2412 KB |
Output is correct |
11 |
Correct |
2 ms |
2412 KB |
Output is correct |
12 |
Correct |
2 ms |
2412 KB |
Output is correct |
13 |
Correct |
2 ms |
2412 KB |
Output is correct |
14 |
Correct |
3 ms |
2412 KB |
Output is correct |
15 |
Correct |
3 ms |
2412 KB |
Output is correct |
16 |
Correct |
2 ms |
2412 KB |
Output is correct |
17 |
Correct |
14 ms |
2412 KB |
Output is correct |
18 |
Correct |
36 ms |
2424 KB |
Output is correct |
19 |
Correct |
23 ms |
2424 KB |
Output is correct |
20 |
Correct |
2 ms |
2424 KB |
Output is correct |
21 |
Correct |
21 ms |
2424 KB |
Output is correct |
22 |
Correct |
27 ms |
2424 KB |
Output is correct |
23 |
Correct |
11 ms |
2424 KB |
Output is correct |
24 |
Correct |
29 ms |
2520 KB |
Output is correct |
25 |
Correct |
39 ms |
2520 KB |
Output is correct |
26 |
Correct |
226 ms |
6284 KB |
Output is correct |
27 |
Correct |
735 ms |
14752 KB |
Output is correct |
28 |
Execution timed out |
1052 ms |
20336 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
20336 KB |
Output is correct |
2 |
Correct |
2 ms |
20336 KB |
Output is correct |
3 |
Correct |
2 ms |
20336 KB |
Output is correct |
4 |
Correct |
2 ms |
20336 KB |
Output is correct |
5 |
Correct |
2 ms |
20336 KB |
Output is correct |
6 |
Correct |
2 ms |
20336 KB |
Output is correct |
7 |
Correct |
2 ms |
20336 KB |
Output is correct |
8 |
Correct |
2 ms |
20336 KB |
Output is correct |
9 |
Correct |
2 ms |
20336 KB |
Output is correct |
10 |
Correct |
2 ms |
20336 KB |
Output is correct |
11 |
Correct |
2 ms |
20336 KB |
Output is correct |
12 |
Correct |
2 ms |
20336 KB |
Output is correct |
13 |
Correct |
3 ms |
20336 KB |
Output is correct |
14 |
Correct |
2 ms |
20336 KB |
Output is correct |
15 |
Correct |
2 ms |
20336 KB |
Output is correct |
16 |
Correct |
2 ms |
20336 KB |
Output is correct |
17 |
Correct |
2 ms |
20336 KB |
Output is correct |
18 |
Correct |
2 ms |
20336 KB |
Output is correct |
19 |
Correct |
2 ms |
20336 KB |
Output is correct |
20 |
Correct |
3 ms |
20336 KB |
Output is correct |
21 |
Correct |
3 ms |
20336 KB |
Output is correct |
22 |
Correct |
2 ms |
20336 KB |
Output is correct |
23 |
Correct |
2 ms |
20336 KB |
Output is correct |
24 |
Correct |
2 ms |
20336 KB |
Output is correct |
25 |
Correct |
2 ms |
20336 KB |
Output is correct |
26 |
Correct |
2 ms |
20336 KB |
Output is correct |
27 |
Incorrect |
2 ms |
20336 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
20336 KB |
Output is correct |
2 |
Correct |
2 ms |
20336 KB |
Output is correct |
3 |
Correct |
2 ms |
20336 KB |
Output is correct |
4 |
Correct |
2 ms |
20336 KB |
Output is correct |
5 |
Correct |
2 ms |
20336 KB |
Output is correct |
6 |
Correct |
2 ms |
20336 KB |
Output is correct |
7 |
Correct |
2 ms |
20336 KB |
Output is correct |
8 |
Correct |
2 ms |
20336 KB |
Output is correct |
9 |
Correct |
2 ms |
20336 KB |
Output is correct |
10 |
Correct |
2 ms |
20336 KB |
Output is correct |
11 |
Correct |
2 ms |
20336 KB |
Output is correct |
12 |
Correct |
2 ms |
20336 KB |
Output is correct |
13 |
Correct |
2 ms |
20336 KB |
Output is correct |
14 |
Incorrect |
2 ms |
20336 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |