제출 #959563

#제출 시각아이디문제언어결과실행 시간메모리
959563HossamHero7Bali Sculptures (APIO15_sculpture)C++14
21 / 100
40 ms608 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; for(int i=0;i<=n+1;i++) dp[n][i] = 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...