답안 #163869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163869 2019-11-15T21:42:02 Z alishahali1382 Editor (BOI15_edi) C++14
0 / 100
2 ms 508 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
using namespace std;
const int MAXN = 300010, LOG=18;

int n, x, ans[MAXN], par[LOG][MAXN], mn[MAXN][LOG];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	for (int i=1; i<=n; i++){
		cin>>x;
		if (x>0){
			for (int j=0; j<LOG; j++) par[i][j]=i;
			ans[i]=x;
		}
		else{
			mn[i][0]=x=-x;
			int v=i-1;
			for (int j=LOG-1; j>=0; j--) if (mn[v][j]>=(-x)) v=par[v][j];
			par[i][0]=v-1;
			for (int j=1; j<LOG; j++){
				par[i][j]=par[par[i][j-1]][j-1];
				mn[i][j]=min(mn[i][j-1], mn[par[i][j-1]][j-1]);
			}
			ans[i]=ans[par[i][0]];
		}
		cout<<ans[i]<<'\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -