Submission #418064

#TimeUsernameProblemLanguageResultExecution timeMemory
418064cgiosyBali Sculptures (APIO15_sculpture)C++17
100 / 100
104 ms452 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; int main() { ios::sync_with_stdio(0);cin.tie(0); int N, S, E; cin>>N>>S>>E; int A[N+1]; for(int i=1; i<=N; i++) cin>>A[i]; ll m=(1LL<<41)-1; int L[N+1], R[N+1]; L[0]=R[0]=0; for(int k=40; k>=0; k--) { m^=1LL<<k; for(int i=1; i<=N; i++) { L[i]=1e9, R[i]=-1e9; ll s=0; for(int j=i-1; j>=0; j--) { s+=A[j+1]; if((s&m)==s) { L[i]=min(L[i], L[j]+1); R[i]=max(R[i], R[j]+1); } } } if(!(S<=R[N] && L[N]<=E)) m^=1LL<<k; } cout<<m<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...