https://www.acwing.com/problem/content/description/602/
找x右边第一个大于x的数的位置
const int N = 1e5 + 10,T = 20;
int n;
LL a[N],stk[N],top,r[N];
void solve()
{
cin >> n;
for (int i = 1;i <= n;i ++) cin >> a[i];
for (int i = n;i >= 1;i --)
{
while(top && a[stk[top]] <= a[i]) top--;
if (top) r[i] = stk[top];
else r[i] = 0;
stk[++top] = i;
}
for (int i = 1;i <= n;i ++)
cout << r[i] << endl;
}