제출 #446466

#제출 시각아이디문제언어결과실행 시간메모리
446466SirCovidThe19thEditor (BOI15_edi)C++14
100 / 100
754 ms50324 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 3e5+5; int n, ans[mx], up[mx][19], mn[mx][19]; int main(){ cin >> n; for (int i = 1; i <= n; i++){ int a; cin >> a; if (a > 0){ ans[i] = a; continue; } a *= -1; int pos = i-1; for (int l = 18; l >= 0; l--) if (mn[pos][l] >= a) pos = up[pos][l]; up[i][0] = pos-1, mn[i][0] = a, ans[i] = ans[pos-1]; for (int l = 1; l < 18; l++){ up[i][l] = up[up[i][l-1]][l-1]; mn[i][l] = min(mn[i][l-1], mn[up[i][l-1]][l-1]); } }for (int i = 1; i <= n; i++) cout<<ans[i]<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...