求助,RE60pts
查看原帖
求助,RE60pts
322620
Nygglatho楼主2021/12/17 18:28

如题,改得几乎跟题解一样了,还是 RE。

#include <bits/stdc++.h>
using namespace std;

stack<int> p, q;

int t[1000001];

int fsr() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') s = s * 10 + ch - 48, ch = getchar();
}

int main() {
	int N;
	
	scanf ("%d", &N);
	
	for (int i = 1; i <= N; ++i) scanf ("%d", &t[i]);
	for (int i = N; i >= 1; --i) {
		while (!p.empty() && t[p.top()] <= t[i]) p.pop();
		if (p.empty()) q.push(0);
		else q.push(p.top());
		p.push(i);
	}
	while(!q.empty()) {printf ("%d ", q.top()); q.pop();}
}
2021/12/17 18:28
加载中...