This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |