标签:space ++ empty main blog using pre int printf
#include<iostream> #include<cstring> #include<cstdio> #include<stack> using namespace std; stack<long long> s; long long a[100005]; int main() { int n; while(scanf("%d",&n) && n) { while(!s.empty()) s.pop(); long long ans = 0; for(int i = 1;i <= n;i++) scanf("%lld",&a[i]); a[n+1] = 0; for(int i = 1;i <= n+1;i++) { while(!s.empty() && a[s.top()] > a[i]) { int temp = s.top(); s.pop(); int len = s.empty()?i-1:i-s.top()-1; ans = max(ans,len*a[temp]); } s.push(i); } printf("%lld\n",ans); } return 0; } //HDU1506
标签:space ++ empty main blog using pre int printf
原文地址:http://www.cnblogs.com/zhurb/p/6034639.html