标签:first mes second while code air pair empty c++
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int maxN=1e6+5; stack<pii> s; int res[maxN]; int main(){ int n,u; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&u); while(!s.empty()&&s.top().first<u){ res[s.top().second]=i+1; s.pop(); } s.push(pii(u,i)); } while(!s.empty()){ res[s.top().second]=0; s.pop(); } for(int i=0;i<n;i++)printf("%d\n",res[i]); }
标签:first mes second while code air pair empty c++
原文地址:https://www.cnblogs.com/TAMING/p/9363395.html