#include <bits/stdc++.h>
using namespace std;
const int N=105,O=(1<<13)+9,MX=1e9+9;
int n,x,y,a[N],pre[N],dp[N][O];
int solve(int pos,int OR){
if(pos==n+1)
return 0;
int &ret=dp[pos][OR];
if(ret!=-1)
return ret;
ret=MX;
for(int i=pos;i<=n;i++)
if( (OR & (pre[i]-pre[pos-1]))==0 )
ret=min(ret,solve(i+1,OR)+1);
return ret;
}
int opposite(int num){
int ret=0;
for(int i=0;i<=11;i++)
if( (num&(1<<i))==0 )
ret|=(1<<i);
return ret;
}
int main(){
cin>>n>>x>>y;
for(int i=1;i<=n;i++)
cin>>a[i],pre[i]=a[i]+pre[i-1];
memset(dp,-1,sizeof(dp));
for(int i=1;i<(1<<12);i++)
if(solve(1,opposite(i))<=y)
cout<<i<<endl,exit(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3712 KB |
Output is correct |
3 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3712 KB |
Output is correct |
3 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3712 KB |
Output is correct |
3 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3712 KB |
Output is correct |
2 |
Correct |
5 ms |
3712 KB |
Output is correct |
3 |
Incorrect |
5 ms |
3712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3712 KB |
Output is correct |
3 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |