#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,a,b;
cin>>n>>a>>b;
int it[n];
for(int i=0;i<n;i++){
cin>>it[i];
}
int dp[n][n][21];
memset(dp,0,sizeof(dp));
/* vector<int> mm[21];
vector<int> nn[21];
for(int mask=0;mask<21;mask++){
for(int submask = mask; ; submask = (submask - 1) & mask) {
mm[mask].pb(submask);
nn[submask].pb(mask);
if(submask == 0) break;
}
}*/
dp[0][0][it[0]]=1;
/*for(int i=0;i<mm[it[0]].size();i++){
dp[0][0][mm[it[0]]][i]=1;
}*/
int pre[n];
pre[0]=it[0];
for(int i=1;i<n;i++){
pre[i]=pre[i-1]+it[i];
}
for(int i=1;i<n;i++){
for(int j=0;j<i;j++){
for(int k=0;k<i;k++){
for(int l=0;l<i;l++){
if(dp[k][j-1][l]){
dp[i][j][l|(pre[i]-pre[k])]=1;
}
}
}
}
}
int ma=23;
for(int i=a-1;i<b;i++){
for(int j=0;j<21;j++){
if(dp[n-1][a][j]==1){
ma=min(ma,j);
}
}
}
cout<<ma<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |