Submission #959565

#TimeUsernameProblemLanguageResultExecution timeMemory
959565HossamHero7Bali Sculptures (APIO15_sculpture)C++14
71 / 100
41 ms604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' bool dp[105][105]; int dp2[105]; void solve(){ int n,l,r; cin>>n>>l>>r; vector<ll> v(n); for(auto &i:v) cin>>i; vector<ll> prefix = v; for(int i=1;i<n;i++) prefix[i] += prefix[i-1]; auto getSum = [&](int i,int j){ return prefix[j] - (i ? prefix[i-1] : 0); }; if(n <= 100){ ll cur = 0; dp[n][0] = 1; for(int bt=41;bt>=0;bt--){ for(int i=n-1;i>=0;i--){ for(int j=0;j<=n;j++){ dp[i][j] = 0; if(j){ for(int k=i;k<n;k++){ if(((getSum(i,k) | cur) >> bt) == (cur>>bt)){ dp[i][j] |= dp[k+1][j-1]; } } } } } for(int i=l;i<=r;i++){ if(dp[0][i]) goto gt; } cur |= (1LL<<(ll)bt); gt:continue; } cout<<cur<<endl; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while(t--){ solve(); } return 0; }
#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...