#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 reversed(int num){//we reverse all the bits up to the 12-th bit
int ret=0;
for(int i=0;i<=12;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=0;i<(1<<12);i++)
if(solve(1,reversed(i))<=y)
cout<<i<<endl,exit(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3712 KB |
Output is correct |
3 |
Correct |
5 ms |
3712 KB |
Output is correct |
4 |
Correct |
7 ms |
3712 KB |
Output is correct |
5 |
Correct |
5 ms |
3712 KB |
Output is correct |
6 |
Correct |
5 ms |
3712 KB |
Output is correct |
7 |
Correct |
5 ms |
3712 KB |
Output is correct |
8 |
Correct |
5 ms |
3712 KB |
Output is correct |
9 |
Correct |
5 ms |
3712 KB |
Output is correct |
10 |
Correct |
4 ms |
3712 KB |
Output is correct |
11 |
Correct |
5 ms |
3712 KB |
Output is correct |
12 |
Correct |
6 ms |
3712 KB |
Output is correct |
13 |
Correct |
7 ms |
3712 KB |
Output is correct |
14 |
Correct |
4 ms |
3712 KB |
Output is correct |
15 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3684 KB |
Output is correct |
3 |
Correct |
4 ms |
3712 KB |
Output is correct |
4 |
Correct |
5 ms |
3712 KB |
Output is correct |
5 |
Correct |
4 ms |
3712 KB |
Output is correct |
6 |
Correct |
5 ms |
3712 KB |
Output is correct |
7 |
Correct |
4 ms |
3712 KB |
Output is correct |
8 |
Correct |
6 ms |
3712 KB |
Output is correct |
9 |
Correct |
4 ms |
3712 KB |
Output is correct |
10 |
Correct |
0 ms |
3712 KB |
Output is correct |
11 |
Correct |
4 ms |
3712 KB |
Output is correct |
12 |
Correct |
5 ms |
3712 KB |
Output is correct |
13 |
Correct |
5 ms |
3712 KB |
Output is correct |
14 |
Correct |
4 ms |
3712 KB |
Output is correct |
15 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
16 |
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 |
Correct |
4 ms |
3740 KB |
Output is correct |
4 |
Correct |
4 ms |
3712 KB |
Output is correct |
5 |
Correct |
4 ms |
3712 KB |
Output is correct |
6 |
Correct |
5 ms |
3712 KB |
Output is correct |
7 |
Correct |
4 ms |
3712 KB |
Output is correct |
8 |
Correct |
4 ms |
3712 KB |
Output is correct |
9 |
Correct |
4 ms |
3712 KB |
Output is correct |
10 |
Correct |
4 ms |
3712 KB |
Output is correct |
11 |
Correct |
4 ms |
3712 KB |
Output is correct |
12 |
Correct |
5 ms |
3712 KB |
Output is correct |
13 |
Correct |
5 ms |
3712 KB |
Output is correct |
14 |
Correct |
4 ms |
3712 KB |
Output is correct |
15 |
Correct |
4 ms |
3712 KB |
Output is correct |
16 |
Correct |
4 ms |
3712 KB |
Output is correct |
17 |
Correct |
4 ms |
3712 KB |
Output is correct |
18 |
Correct |
4 ms |
3712 KB |
Output is correct |
19 |
Correct |
4 ms |
3712 KB |
Output is correct |
20 |
Correct |
5 ms |
3712 KB |
Output is correct |
21 |
Correct |
5 ms |
3712 KB |
Output is correct |
22 |
Correct |
4 ms |
3712 KB |
Output is correct |
23 |
Correct |
4 ms |
3712 KB |
Output is correct |
24 |
Correct |
4 ms |
3712 KB |
Output is correct |
25 |
Correct |
4 ms |
3712 KB |
Output is correct |
26 |
Correct |
5 ms |
3712 KB |
Output is correct |
27 |
Correct |
4 ms |
3712 KB |
Output is correct |
28 |
Correct |
4 ms |
3712 KB |
Output is correct |
29 |
Correct |
4 ms |
3712 KB |
Output is correct |
30 |
Correct |
13 ms |
3840 KB |
Output is correct |
31 |
Correct |
4 ms |
3712 KB |
Output is correct |
32 |
Correct |
4 ms |
3712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3712 KB |
Output is correct |
2 |
Correct |
4 ms |
3736 KB |
Output is correct |
3 |
Correct |
4 ms |
3712 KB |
Output is correct |
4 |
Correct |
4 ms |
3712 KB |
Output is correct |
5 |
Correct |
4 ms |
3584 KB |
Output is correct |
6 |
Correct |
4 ms |
3712 KB |
Output is correct |
7 |
Correct |
4 ms |
3712 KB |
Output is correct |
8 |
Correct |
4 ms |
3840 KB |
Output is correct |
9 |
Correct |
4 ms |
3712 KB |
Output is correct |
10 |
Correct |
4 ms |
3712 KB |
Output is correct |
11 |
Correct |
4 ms |
3712 KB |
Output is correct |
12 |
Correct |
4 ms |
3712 KB |
Output is correct |
13 |
Correct |
4 ms |
3712 KB |
Output is correct |
14 |
Correct |
4 ms |
3712 KB |
Output is correct |
15 |
Incorrect |
4 ms |
3684 KB |
Output isn't correct |
16 |
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 |
Correct |
4 ms |
3712 KB |
Output is correct |
4 |
Correct |
4 ms |
3712 KB |
Output is correct |
5 |
Correct |
4 ms |
3712 KB |
Output is correct |
6 |
Correct |
4 ms |
3712 KB |
Output is correct |
7 |
Correct |
4 ms |
3712 KB |
Output is correct |
8 |
Correct |
4 ms |
3712 KB |
Output is correct |
9 |
Correct |
4 ms |
3712 KB |
Output is correct |
10 |
Correct |
4 ms |
3712 KB |
Output is correct |
11 |
Correct |
4 ms |
3712 KB |
Output is correct |
12 |
Correct |
4 ms |
3712 KB |
Output is correct |
13 |
Correct |
4 ms |
3712 KB |
Output is correct |
14 |
Incorrect |
4 ms |
3712 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |