This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=2005;
int tab[MAX];
int32_t main()
{
BOOST;
int n,a,b;
cin>>n>>a>>b;
for (int i=0;i<n;i++)cin>>tab[i];
ll ans=0;
for (int i=40;i>=0;i--)
{
vector<bitset<MAX>>dp(n+1);
dp[0]=1;
for (int j=1;j<=n;j++)
{
ll akt=0;
for (int k=j-1;k>=0;k--)
{
akt+=tab[k];
if (!(akt&(1LL<<i)) && ((ans|(akt>>(i+1)))==ans))dp[j]|=(dp[k]<<1);
}
}
bool t=false;
for (int j=a;j<=b;j++) if (dp[n][j]){t=true;break;}
ans*=2;
if (!t)ans++;
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |