标签:链接 ict 两种 scanf can enc cli ble single
题目链接 :http://acm.hdu.edu.cn/showproblem.php?pid=1506
#include<bits/stdc++.h> using namespace std; const int N=1e5+7; typedef long long ll; ll arr[N]; int main(){ int n; while(cin>>n,n){ stack<int >st; for(int i=1;i<=n;i++) scanf("%lld",&arr[i]); arr[n+1]=0; long long ans=0; for(int i=1;i<=n+1;i++){ if(st.empty()||arr[i]>=arr[st.top()]){ st.push(i); } else { int x=st.top(); while(st.size()&&arr[i]<arr[x]){ st.pop(); if(st.size()){ ans=max(ans,arr[x]*(i-st.top()-1)); x=st.top(); } else ans=max(ans,arr[x]*(i-1)); } st.push(i); } } cout<<ans<<endl; } return 0; }
Largest Rectangle in a Histogram 杭电1506
标签:链接 ict 两种 scanf can enc cli ble single
原文地址:https://www.cnblogs.com/Accepting/p/11602426.html