#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
long long Arr[N];
long long pre[N];
int main()
{
ios_base::sync_with_stdio(false);
int n,a,b;
cin >> n >> a >> b;
set<int> x;
for(int i =1;i<=n;i++) {
cin >> Arr[i];
pre[i] = Arr[i] + pre[i-1];
}
pre[n+1] = pre[n];
x.insert(1);
x.insert(n+1);
long long ans = pre[n];
while(b--) {
int ind = 0;
long long temp =ans;
for(int i =2;i<=n;i++) {
if(x.count(i)) continue;
x.insert(i);
auto j = x.begin();
long long tt = 0;
j++;
for(;j!=x.end();j++) {
auto z = j;
z--;
tt |= pre[*j-1] - pre[*z-1];
}
x.erase(i);
if(tt <= temp) {
temp = tt;
ind = i;
}
}
ans = temp;
x.insert(ind);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
388 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |