答案跟测试点一样却WA
  • 板块P1165 日志分析
  • 楼主nalemy
  • 当前回复4
  • 已保存回复4
  • 发布时间2020/7/29 13:05
  • 上次更新2023/11/6 21:52:34
查看原帖
答案跟测试点一样却WA
360214
nalemy楼主2020/7/29 13:05

本机过,本机答案与测试点答案一模一样,洛谷全WA

贴代码:

#include <iostream>
#define N 200000
using namespace std;

int top;
int stack[N];
int main() {
	// freopen("1165.out", "w", stdout);
	int n, c;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> c;
		stack[0] = 0;
		if (c == 0) {
			int x;
			cin >> x;
//			cout << "TOP:" << top << " stack[top]:" << stack[top] << "  x:" << x << "  mx:" << max(stack[top], x) << endl;
			stack[top+1] = max(stack[top++], x);
//			cout << "stack[top]:" << stack[top] << endl;
		}else if (c == 1) {
			top = max(top-1, 0);
		}else if (c == 2) {
//			cout << "STK:";for (int i=0; i<=top; i++) cout << stack[i] << " ";cout << endl;
			cout << stack[top] << endl;
		}
	}
	return 0;
}

2020/7/29 13:05
加载中...