标签:最大的 bsp ecif pre i++ ase rip tle alc
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[100005]; int l[100005],r[100005]; int main() { int n; while(scanf("%d",&n) && n != 0) { long long ans=0; memset(a,0,sizeof(a)); for(int i = 0;i<n;i++) { scanf("%d",&a[i]); l[i] = r[i] = i; while(l[i] > 0 && a[l[i]-1] >= a[i]) { l[i] = l[l[i]-1]; } } for(int i = n-1;i>=0;i--) { while(r[i]<n-1 && a[r[i]+1] >= a[i]) { r[i] = r[r[i]+1]; } } for(int i = 0;i<n;i++) { long long s = (long long)a[i]*(r[i]-l[i]+1); if(s>ans) { ans = s; } } printf("%lld\n",ans); } return 0; }
标签:最大的 bsp ecif pre i++ ase rip tle alc
原文地址:https://www.cnblogs.com/hdyss/p/10853303.html