#include "bits/stdc++.h" using namespace std; const int N=1e5+3; #define int long long int n,a[N]; int hh,stk[N],w[N]; void sov(){ hh=0; memset(a,0,sizeof a); stk[n+1]=w[n+1]=0; int i,ans=0; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n+1;i++){ int t=0; while(hh>0&&stk[hh]>=a[i]){ t+=w[hh]; ans=max(ans,t*stk[hh]); hh--; } stk[++hh]=a[i]; w[hh]=t+1; } cout<<ans<<endl; } main(){ while(cin>>n,n) sov(); }
标签:int,hh,stk,直方图,acwing131,ans,矩形 From: https://www.cnblogs.com/towboa/p/16940215.html