제출 #827621

#제출 시각아이디문제언어결과실행 시간메모리
827621Darren0724Editor (BOI15_edi)C++17
100 / 100
123 ms26944 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(){ ios_base::sync_with_stdio(false); cin.tie(0); 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)]<<'\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...