你这应该这样啊:
```cpp
for(int i=1;i<=n+1;i++){
if(st.empty()||h[st.top()]<=h[i])st.push(i);
while(!st.empty()&&h[st.top()]>h[i]){
int pos=st.top(); st.pop();
int len=i-pos;
ans=max(ans,1ll*len*h[pos]);
}
}
by wangjingtian1234 @ 2023-08-14 11:08:52
不对
by wangjingtian1234 @ 2023-08-14 11:10:59
```cpp
for(int i=1;i<=n+1;i++){
if(st.empty()||h[st.top()]<=h[i])st.push(i);
else
{
int pos;
while(!st.empty()&&h[st.top()]>h[i]){
pos=st.top(); st.pop();
int len=i-pos;
ans=max(ans,1ll*len*h[pos]);
}
st.push(pos);
h[pos] = h[i];
}
}
printf("%lld\n",ans);
by wangjingtian1234 @ 2023-08-14 11:13:12
这样
by wangjingtian1234 @ 2023-08-14 11:13:29