이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* upsolve after reading analysis */
#include <stdio.h>
#define N	300000
#define L	18	/* L = pow2(log2(N - 1)) */
int min(int a, int b) { return a < b ? a : b; }
int main() {
	static int aa[N], pp[N][L + 1], aa_[N][L + 1], ll[N], ans[N];
	int n, i, l;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		if (a > 0) {
			aa[i] = 0, ans[i] = a;
			pp[i][0] = i - 1, aa_[i][0] = aa[i];
			for (l = 0; pp[i][l] != -1; l++) {
				int p = pp[i][l];
				pp[i][l + 1] = pp[p][l];
				aa_[i][l + 1] = min(aa_[i][l], aa_[p][l]);
			}
			ll[i] = l;
		} else {
			int p;
			aa[i] = -a;
			for (p = i - 1, l = ll[p]; l >= 0; l--)
				if (l <= ll[p] && aa[i] <= aa_[p][l])
					p = pp[p][l];
			p--;
			ans[i] = p == -1 ? 0 : ans[p];
			pp[i][0] = p, aa_[i][0] = aa[i];
			for (l = 0; (p = pp[i][l]) != -1; l++) {
				pp[i][l + 1] = pp[p][l];
				aa_[i][l + 1] = min(aa_[i][l], aa_[p][l]);
			}
			ll[i] = l;
		}
		printf("%d\n", ans[i]);
	}
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
edi.c: In function 'main':
edi.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
edi.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |