AT_donuts_2015_3 题解
题目传送门
题目大意
有
思路
考虑使用单调栈。用单调栈维护一个身高递减的序列,第
AC CODE
#include<bits/stdc++.h>
using namespace std;
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
const int N=1e5+10;
int a[N];
stack<int>st;
int main(){
int n=read();
for(int i=1;i<=n;++i){
a[i]=read();
printf("%llu\n",st.size());
while(!st.empty()&&st.top()<a[i])
st.pop();
st.push(a[i]);
}
return 0;
}