“#include<bits/stdc++.h> using namespace std; inline int read(){//快读,不用理他 int wow=0,f=1; char c=getchar(); while(c>‘9’ || c<‘0’){ if(c==’-’){ f=-f; } c=getchar(); } while(c>=‘0’ && c<=‘9’){ wow=(wow<<3)+(wow<<1)+c-‘0’; c=getchar(); } return wow*f; } const int N=3e6+5; int n,a[N],ans[N],q[N];
int main(){ cin>>n; for(int i=1;i<=n;i++) a[i]=read(); int top=0; for(int i=1;i<=n;i++){ while(top>0 && a[q[top]]<a[i]){//当栈不为空且当前值大于栈顶 ans[q[top]]=i;//设置“第一个比qtop大的位置” top—;//出栈 } q[++top]=i; } for(int i=1;i<=n;i++) cout<<ans[i]<<” ”;
}”