# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846534 | lovrot | Editor (BOI15_edi) | C++17 | 210 ms | 27932 KiB |
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 <cstdio>
using namespace std;
const int N = 3e5 + 10;
const int LOG = 19;
int n, A[N];
int UP[N][LOG];
int climb(int u, int val) {
for(int i = LOG - 1; i >= 0; --i)
if(A[UP[u][i]] <= val) {
u = UP[u][i];
}
if(A[u] > val) return u;
return UP[u][0];
}
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
scanf("%d", A + i);
if(A[i] < 0) {
UP[i][0] = climb(climb(i - 1, A[i]) - 1, A[i]);
for(int j = 1; j < LOG; ++j) UP[i][j] = UP[UP[i][j - 1]][j - 1];
}
printf("%d\n", A[climb(i, -1)]);
}
return 0;
}
Compilation message (stderr)
# | 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... |