제출 #827608

#제출 시각아이디문제언어결과실행 시간메모리
827608Darren0724Editor (BOI15_edi)C++17
100 / 100
506 ms29036 KiB
#include<bits/stdc++.h> using namespace std; int v[300005]; int jump[20][300005]; int Find(int k,int lv){ if(-v[k]<=lv)return k; for(int j=19;j>=0;j--){ if(-v[jump[j][k]]>lv){ k=jump[j][k]; } } return jump[0][k]; } int main(){ int n;cin>>n; for(int i=1;i<=n;i++){ cin>>v[i]; if(v[i]<0){ int tmp=Find(i-1,-v[i]-1)-1; int pa=Find(tmp,-v[i]-1); jump[0][i]=pa; for(int j=1;j<20;j++){ jump[j][i]=jump[j-1][jump[j-1][i]]; } } cout<<v[Find(i,0)]<<endl; } 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...