Submission #15869

#TimeUsernameProblemLanguageResultExecution timeMemory
15869myungwooBali Sculptures (APIO15_sculpture)C++14
50 / 100
302 ms5680 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 2003 typedef long long lld; int N, A, B; int X[MAXN], D[MAXN], E[MAXN]; lld S[MAXN]; bool w[MAXN][MAXN]; int main() { scanf("%d%d%d", &N, &A, &B); for (int i=1;i<=N;i++) scanf("%d", X+i), S[i] = S[i-1] + X[i]; lld msk = 0; for (int b=40;b>=0;b--){ for (int i=0;i<N;i++) for (int j=i+1;j<=N;j++){ w[i][j] = (((S[j]-S[i]) >> b) | msk) == msk; } D[0] = E[0] = 0; for (int i=1;i<=N;i++){ D[i] = 2e9; E[i] = -2e9; for (int j=0;j<i;j++) if (w[j][i]){ if (D[j] >= 0) D[i] = min(D[i], D[j]+1); if (E[j] < 2e9) E[i] = max(E[i], E[j]+1); } } if (D[N] <= B); else msk++; if (b) msk <<= 1; } printf("%lld\n", msk); }
#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...