| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 544719 | rainboy | Editor (BOI15_edi) | C11 | 230 ms | 51276 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.
/* upsolve after reading analysis */
#include <stdio.h>
#define N 300000
#define L 18 /* L = pow2(log2(N - 1)) */
int min(int a, int b) { return a < b ? a : b; }
int main() {
static int aa[N], pp[N][L + 1], aa_[N][L + 1], ll[N], ans[N];
int n, i, l;
scanf("%d", &n);
for (i = 0; i < n; i++) {
int a;
scanf("%d", &a);
if (a > 0) {
aa[i] = 0, ans[i] = a;
pp[i][0] = i - 1, aa_[i][0] = aa[i];
for (l = 0; pp[i][l] != -1; l++) {
int p = pp[i][l];
pp[i][l + 1] = pp[p][l];
aa_[i][l + 1] = min(aa_[i][l], aa_[p][l]);
}
ll[i] = l;
} else {
int p;
aa[i] = -a;
for (p = i - 1, l = ll[p]; l >= 0; l--)
if (l <= ll[p] && aa[i] <= aa_[p][l])
p = pp[p][l];
p--;
ans[i] = p == -1 ? 0 : ans[p];
pp[i][0] = p, aa_[i][0] = aa[i];
for (l = 0; (p = pp[i][l]) != -1; l++) {
pp[i][l + 1] = pp[p][l];
aa_[i][l + 1] = min(aa_[i][l], aa_[p][l]);
}
ll[i] = l;
}
printf("%d\n", ans[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... | ||||
