#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXN=2048;
vector<pair<ll,ll> >g[MAXN];
ll n,a,b,cur;
ll y[MAXN];
bool dp[MAXN][MAXN];
bool ok(ll idx)
{
//if(idx==1)cout<<idx<<endl;
memset(dp,0,sizeof(dp));
dp[0][0]=1;
for(int i=0;i<=n;i++)
{
for(auto xd:g[i])
{
//if(idx==1)cout<<xd.first<<" "<<(xd.first&(~cur))<<" "<<(1ll<<idx)<<endl;
if((xd.first|cur)!=cur)continue;
//if(idx==1)cout<<i<<" "<<xd.second<<endl;
for(int j=0;j<=n;j++)
{
dp[xd.second+1][j+1]|=dp[i][j];
}
}
}
for(int i=a;i<=b;i++)
{
if(dp[n+1][i])return 1;
}
return 0;
}
int main()
{
cin>>n>>a>>b;
for(ll i=1;i<=n;i++)
{
cin>>y[i];
}
for(int i=0;i<=n;i++)
{
int sum=0;
for(int j=i;j<=n;j++)
{
sum+=y[j];
g[i].push_back({sum,j});
}
}
cur=(1ll<<51)-1;
for(ll i=50;i>=0;i--)
{
if(ok(cur-(1ll<<i)))
{
cur-=(1ll<<i);
}
}
cout<<cur<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
4460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
4460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
4460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
4460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
4460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |