# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134326 | Kastanda | Editor (BOI15_edi) | C++11 | 263 ms | 50216 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.
// ItnoE
#include<bits/stdc++.h>
using namespace std;
const int N = 300005, LG = 19;
int n, R[N], P[N][LG], M[N][LG];
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i ++)
{
int a;
scanf("%d", &a);
if (a > 0)
{
P[i][0] = i;
R[i] = a;
continue;
}
a = - a;
int nw = i - 1;
for (int j = LG - 1; ~ j; j --)
if (M[nw][j] >= a)
nw = P[nw][j];
P[i][0] = nw - 1;
R[i] = R[P[i][0]];
M[i][0] = a;
for (int j = 1; j < LG; j ++)
P[i][j] = P[P[i][j - 1]][j - 1],
M[i][j] = min(M[i][j - 1], M[P[i][j - 1]][j - 1]);
}
for (int i = 1; i <= n; i ++)
printf("%d\n", R[i]);
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... |