#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n,a,b;cin>>n>>a>>b;
vector<long long>arr(n);
for (long long i = 0;i<n;++i){
cin>>arr[i];
}
const long long inf = 1e15;
vector<long long>pref(n + 1,0);
for (int i = 0;i<n;++i){
pref[i + 1] = pref[i] + arr[i];
}
auto query = [&](int u,int v){
return pref[v + 1] - pref[u];
};
vector<vector<long long>>dp(n,vector<long long>(n,-1));
function<long long(int,int)>solve = [&](int u,int kk){
if (kk > b)return inf;
if (u == n){
if (kk >= a && kk <= b){
return 0LL;
}
return inf;
}
if (dp[u][kk]!= -1){
return dp[u][kk];
}
long long ans = inf;
if (kk >= a && kk <= b)ans = 0;
for (int i = u + 1;i<=n;++i){
ans = min(ans,(solve(i,kk + 1) | query(u,i - 1)));
}
return dp[u][kk] = ans;
};
cout<<solve(0,0)<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |