#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
int dp[101][101][2050], a[110], p[110], n;
int f(int i, int k, int o) {
if(k > i) return 1e9;
if(k == 1) return p[i] | o;
int &ret = dp[i][k][o];
if(ret != -1) return ret;
int sum = a[i];
ret = 1e9;
for(int j = i - 1; j >= 1; j--) {
ret = min(ret, f(j, k - 1, sum | o) | sum | o);
sum += a[j];
}
return 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];
}
memset(dp, -1, sizeof dp);
cout << f(n, r, 0) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
82168 KB |
Output is correct |
2 |
Correct |
61 ms |
82168 KB |
Output is correct |
3 |
Correct |
61 ms |
82216 KB |
Output is correct |
4 |
Correct |
68 ms |
82248 KB |
Output is correct |
5 |
Correct |
62 ms |
82252 KB |
Output is correct |
6 |
Incorrect |
61 ms |
82268 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
82324 KB |
Output is correct |
2 |
Correct |
72 ms |
82324 KB |
Output is correct |
3 |
Correct |
60 ms |
82356 KB |
Output is correct |
4 |
Correct |
62 ms |
82396 KB |
Output is correct |
5 |
Correct |
74 ms |
82396 KB |
Output is correct |
6 |
Incorrect |
65 ms |
82480 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
82480 KB |
Output is correct |
2 |
Correct |
60 ms |
82480 KB |
Output is correct |
3 |
Correct |
63 ms |
82480 KB |
Output is correct |
4 |
Correct |
62 ms |
82480 KB |
Output is correct |
5 |
Correct |
62 ms |
82480 KB |
Output is correct |
6 |
Incorrect |
62 ms |
82480 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
82524 KB |
Output is correct |
2 |
Correct |
62 ms |
82524 KB |
Output is correct |
3 |
Correct |
62 ms |
82524 KB |
Output is correct |
4 |
Correct |
65 ms |
82524 KB |
Output is correct |
5 |
Correct |
62 ms |
82524 KB |
Output is correct |
6 |
Incorrect |
63 ms |
82524 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
82524 KB |
Output is correct |
2 |
Correct |
61 ms |
82524 KB |
Output is correct |
3 |
Correct |
60 ms |
82524 KB |
Output is correct |
4 |
Correct |
65 ms |
82524 KB |
Output is correct |
5 |
Correct |
61 ms |
82524 KB |
Output is correct |
6 |
Incorrect |
66 ms |
82524 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |