제출 #987341

#제출 시각아이디문제언어결과실행 시간메모리
987341lucriEditor (BOI15_edi)C++17
35 / 100
3026 ms10836 KiB
#include <bits/stdc++.h> using namespace std; long long n,v[300010],ans[300010],ant[300010]; int main() { cin>>n; for(int i=1;i<=n;++i) { cin>>v[i]; if(v[i]>0) { ans[i]=v[i]; ant[i]=i-1; continue; } int poz=i-1; while(v[poz]<=v[i]) { poz=ant[poz]; } ant[i]=poz-1; ans[i]=ans[ant[i]]; } for(int i=1;i<=n;++i) cout<<ans[i]<<'\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...