# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
660153 | kinope | Editor (BOI15_edi) | C++14 | 3075 ms | 8532 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 <bits/stdc++.h>
using namespace std;
struct p{
int v; bool on;
};
int main(){
int n;
scanf("%d", &n);
vector<p> act(n);
vector<int> ojc(n, -1);
set<pair<int, int>> s;
for(int i = 0; i < n; ++i){
int a;
scanf("%d", &a);
if(a > 0){
act[i] = {a, 1};
s.emplace(i, a);
printf("%d\n", (*prev(s.end())).second);
continue;
}
act[i] = {a, 1};
for(int j = i-1; ~j; --j) if(act[j].on && act[j].v > a){
ojc[i] = j;
for(int x = j; ~x; x = ojc[x]){
act[x].on^=1;
if(ojc[x] < 0){
pair<int, int> tmp = {x, act[x].v};
if(act[x].on) s.emplace(x, act[x].v);
else s.erase(tmp);
}
}
break;
}
if(s.empty()) printf("0\n");
else printf("%d\n", (*prev(s.end())).second);
}
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... |