이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int64_t 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);
llo n,a,b;
cin>>n>>a>>b;
llo it[n];
for(llo i=0;i<n;i++){
cin>>it[i];
}
llo dp[n];
llo ans=0;
memset(dp,0,sizeof(dp));
llo pre[n];
pre[0]=it[0];
for(llo i=1;i<n;i++){
pre[i]=pre[i-1]+it[i];
}
for(llo i=42;i>=0;i--){
memset(dp,0,sizeof(dp));
//cout<<ans<<endl;
ans=ans+(((llo)1<<(i))-(llo)1);
// cout<<i<<endl;
//cout<<ans<<endl;
for(llo j=0;j<n;j++){
llo no=pre[j];
no|=ans;
if(no==ans){
dp[j]=1;
}
for(llo l=0;l<j;l++){
llo no=(pre[j]-pre[l]);
no|=ans;
if(dp[l]==1 and (no==ans)){
if(dp[j]==0){
dp[j]=dp[l]+1;
}
dp[j]=min(dp[j],dp[l]+1);
}
}
}
ans-=(llo)(((llo)1<<(i))-(llo)1);
//cout<<ans<<endl<<endl;
llo st=1;
for(llo j=n-1;j<n;j++){
if(dp[j]>0 and dp[j]<b+1){
st=0;
break;
}
}
if(st){
ans|=((llo)1<<i);
}
}
cout<<ans<<endl;
/*llo nno=8|3;
//cout<<nno<<endl;
*/
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... |