#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;
const int k = 15;
auto query = [&](int u,int v){
long long ans = 0;
for (int i = u;i<=v;++i){
ans+=arr[i];
}
return ans;
};
vector<vector<vector<long long>>>dp(n,vector<vector<long long>>(n,vector<long long>(n,-1)));
function<long long(int,int,int)>solve = [&](int u,int v,int kk){
if (u == n){
if (kk >= a && kk < b){
return 0LL;
}
return inf;
}
if (dp[u][v][kk]!= -1){
return dp[u][v][kk];
}
long long ans = inf;
for (int i = u + 1;i<=n;++i){
ans = min(ans,(solve(i,u,kk + 1) | query(u,i - 1)));
}
return dp[u][v][kk] = ans;
};
cout<<solve(0,0,0)<<'\n';
return 0;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:12:12: warning: unused variable 'k' [-Wunused-variable]
12 | const int k = 15;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
272 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |