Submission #120008

#TimeUsernameProblemLanguageResultExecution timeMemory
120008E869120Editor (BOI15_edi)C++14
20 / 100
3059 ms2176 KiB
#include <iostream> using namespace std; int N, A[300009], P[300009], par[300009]; int main() { cin >> N; for (int i = 1; i <= N; i++) cin >> A[i]; for (int i = 1; i <= N; i++) { if (A[i] >= 0) { P[i] = 1; } else { P[i] = 1; for (int j = i - 1; j >= 1; j--) { int level = 0; if (A[j] < 0) level = -A[j]; if (level < -A[i] && P[j] == 1) { par[i] = j; break; } } int cx = i; while (A[cx] < 0) { cx = par[cx]; P[cx] ^= 1; } } int ans = 0; for (int j = 1; j <= i; j++) { if (P[j] == 1 && A[j] >= 1) ans = A[j]; } cout << ans << endl; } 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...