# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1127323 | Kerim | Editor (BOI15_edi) | C++20 | 3093 ms | 10372 KiB |
#include "bits/stdc++.h"
using namespace std;
struct edi{
int val;
int lvl;
int par;
bool active;
edi(int _val, int _lvl){
par = -1;
val = _val;
lvl = _lvl;
active = 0;
}
};
int main(){
// freopen("file.in", "r", stdin);
int n;
scanf("%d", &n);
vector<edi> v;
v.push_back(edi(0, 0));
v[0].active = 1;
for (int i = 1; i <= n; i++){
int x;
scanf("%d", &x);
if (x > 0)
v.push_back(edi(x, 0));
else{
v.push_back(edi(-1, -x));
//need to be optimized
for (int j = i; j >= 0; j--){
if (v[j].active and v[j].lvl < v.back().lvl){
v[i].par = j;
break;
}
}
}
//need to be optimized
int cur = i;
while (~cur){
v[cur].active ^= 1;
cur = v[cur].par;
}
//need to be optimized
int ans;
for (int j = i; j >= 0; j--)
if (v[j].active and v[j].lvl < 1){
ans = j;
break;
}
printf("%d\n", v[ans].val);
}
}
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... |