语言: 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;
}