제출 #556015

#제출 시각아이디문제언어결과실행 시간메모리
556015stefantagaEditor (BOI15_edi)C++14
100 / 100
174 ms30156 KiB
#include <bits/stdc++.h> using namespace std; int rmq[300005][20],n,i,v[300005],lev[300005],sal,j; int parinte(int x,int nivel) { if (lev[x]<=nivel) { return x; } for (int i=19;i>=0;i--) { if (lev[rmq[x][i]]>nivel) { x=rmq[x][i]; } } return rmq[x][0]; } int main() { ios_base :: sync_with_stdio(false); cin.tie(0); #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n; for (i=1;i<=n;i++) { cin>>v[i]; lev[i]=max(0,-v[i]); if (v[i]<0) { sal = parinte(i-1,lev[i]-1); assert(sal); rmq[i][0]=parinte(sal-1,lev[i]-1); assert(lev[i]>lev[rmq[i][0]]); for (j=1;j<=19;j++) { rmq[i][j]=rmq[rmq[i][j-1]][j-1]; } } cout<<v[parinte(i,0)]<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...