제출 #120007

#제출 시각아이디문제언어결과실행 시간메모리
120007E869120Editor (BOI15_edi)C++14
20 / 100
45 ms1452 KiB
#include <iostream> using namespace std; int N, A[100009], P[100009], par[100009]; 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...