제출 #529350

#제출 시각아이디문제언어결과실행 시간메모리
529350HanksburgerBali Sculptures (APIO15_sculpture)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; long long dp1[2005][2005], dp2[2005], a[2005], b[2005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, l, r, loog, cur=0; cin >> n >> l >> r; for (long long i=1; i<=n; i++) cin >> a[i]; for (long long i=1; i<=n; i++) b[i]=b[i-1]+a[i]; loog=log2(b[n]); if (l==1) { for (long long i=loog; i>=0; i--) { cur|=1<<i; dp2[0]=0; for (long long j=1; j<=n; j++) dp2[j]=1e18; for (long long j=1; j<=n; j++) for (long long k=0; k<j; k++) if (!(cur&(b[j]-b[k]))) dp2[j]=min(dp2[j], dp2[k]+1); if (dp2[n]>r) cur^=1<<i; } } else { long long cur=0; for (long long i=loog; i>=0; i--) { cur|=1<<i; dp1[0][0]=1; for (long long j=1; j<=n; j++) for (long long k=1; k<=j; k++) dp1[j][k]=0; for (long long j=1; j<=n; j++) { for (long long k=1; k<=j; k++) { for (long long m=k-1; m<j; m++) if (!(cur&(b[j]-b[m]))) dp1[j][k]=1; } } bool imp=1; for (long long i=l; i<=r; i++) { if (dp1[n][i]) { imp=0; break; } } if (imp) cur^=1<<i; } } cout << pow(2, loog+1)-cur-1; 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...