답안 #120133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120133 2019-06-23T13:57:43 Z E869120 Editor (BOI15_edi) C++14
0 / 100
528 ms 57016 KB
#include <iostream>
#include <algorithm>
using namespace std;

int N, A[1 << 19], dp[1 << 19][22], ret[1 << 19], dp2[1 << 19][22];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] > 0) { for (int j = 0; j <= 21; j++) { dp[i][j] = i; dp2[i][j] = 0; } ret[i] = A[i]; }
		else {
			int cx = i - 1, level = -A[i];
			for (int j = 21; j >= 0; j--) {
				if (dp2[cx][j] >= level) cx = dp[cx][j];
			}
			cx--;
			if (cx == 0) { ret[i] = 0; for (int j = 0; j <= 21; j++) dp2[i][j] = level; }
			else {
				ret[i] = ret[cx];
				dp[i][0] = cx; dp2[i][0] = level;
				for (int j = 1; j <= 21; j++) {
					dp[i][j] = dp[dp[i][j - 1]][j - 1];
					dp2[i][j] = min(dp2[i][j - 1], dp2[dp[i][j]][j - 1]);
				}
			}
		}
	}
	for (int i = 1; i <= N; i++) cout << ret[i] << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 528 ms 57016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 272 ms 29028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -