60求助
查看原帖
60求助
571740
yuhaoran666楼主2022/7/12 17:06

语言: C++

#include<bits/stdc++.h>
using namespace std;
stack<int> a;
int n, tmp, b[10000010];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++) {
		tmp = i + 1;
		for (int j = n; j >= i + 1; j--) a.push(b[j]);
		while (!a.empty() && a.top() <= b[i]) a.pop(), tmp++;
		cout << (!a.empty() ? (tmp + 1):0) << " ";
		while (!a.empty()) a.pop();
	}
	return 0;
}
2022/7/12 17:06
加载中...