# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
998045 | guagua0407 | Editor (BOI15_edi) | C++17 | 164 ms | 30292 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.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int mxn=3e5+5;
int prv[mxn][20];
int e[mxn];
int lev[mxn];
int cur=0;
int main() {_
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>e[i];
e[i]*=-1;
lev[i]=max(0,e[i]);
if(e[i]>0){
int x=i-1;
for(int j=19;j>=0;j--){
if(lev[prv[x][j]]>=lev[i]){
x=prv[x][j];
}
}
x=prv[x][0];
if(lev[i-1]<lev[i]){
x=i-1;
}
int y=x-1;
for(int j=19;j>=0;j--){
if(lev[prv[y][j]]>=lev[i]){
y=prv[y][j];
}
}
y=prv[y][0];
if(lev[x-1]<lev[i]){
y=x-1;
}
prv[i][0]=y;
for(int j=1;j<20;j++){
prv[i][j]=prv[prv[i][j-1]][j-1];
}
}
int ans=i;
for(int j=19;j>=0;j--){
if(lev[prv[ans][j]]>0){
ans=prv[ans][j];
}
}
if(lev[ans]>0) ans=prv[ans][0];
cout<<-e[ans]<<'\n';
}
return 0;
}
//maybe its multiset not set
//yeeorz
//laborz
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... |