# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951501 | Trisanu_Das | Editor (BOI15_edi) | C++17 | 168 ms | 51328 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;
const int N=300050;
const int L=19;
int a[N],go[N][L],mn[N][L],ans[N];
int main(){
int n;
scanf("%i",&n);
for(int i=1;i<=n;i++){
scanf("%i",&a[i]);
if(a[i]>0)ans[i]=a[i];
else{
int x=-a[i];
int j=i-1;
for(int k=L-1;~k;k--)if(mn[j][k]>=x)j=go[j][k];
ans[i]=ans[j-1];
go[i][0]=j-1;
mn[i][0]=x;
for(int k=1;k<L;k++){
go[i][k]=go[go[i][k-1]][k-1];
mn[i][k]=min(mn[i][k-1],mn[go[i][k-1]][k-1]);
}
}
printf("%i\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... |