# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44639 | RayaBurong25_1 | Editor (BOI15_edi) | C++17 | 3043 ms | 7340 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 <stdio.h>
#include <vector>
int Val[300005];
typedef struct node node;
struct node
{
int level;
int last;
int next;
};
node Last[300005];
// std::vector<std::pair<int, int> > Last[300005];
int main()
{
int N;
scanf("%d", &N);
int i, x;
// std::vector<std::pair<int, int> >::iterator it;
int j;
for (i = 1; i <= N; i++)
{
scanf("%d", &x);
if (x > 0)
{
Val[i] = x;
// Last[i] = Last[i - 1];
// Last[i].push_back({0, i - 1});
Last[i] = {0, i - 1, i - 1};
printf("%d\n", Val[i]);
}
else
{
// it = Last[i - 1].end();
// it--;
// while (it->first <= x) it--;
j = i - 1;
while (Last[j].level <= x) j = Last[j].next;
j = Last[j].last;
Val[i] = Val[j];
// Last[i] = Last[it->second];
// Last[i].push_back({x, i - 1});
Last[i] = {x, i - 1, j};
printf("%d\n", Val[i]);
}
}
}
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... |