啥时候降绿了
上次传错代码了,怪不得没人理我
#include <bits/stdc++.h>
using namespace std;
int a[1000010],b[1000010];
int sta[1000010],top=0;
int main(){
int n;
while(scanf("%d",&n) and n){
for(int i=1;i<=n;++i){
scanf("%d",&a[i]);
}
a[n+1]=0;
int maxn=0,x=0;
for(int i=1;i<=n+1;++i){
if(a[i]>sta[top]){
sta[++top]=a[i];
b[top]=1;
continue;
}
else{
x=0;
while(a[i]<sta[top]){
x+=b[top];
maxn=max(sta[top]*x,maxn);
top--;
}
sta[++top]=a[i],b[top]=x+1;
}
}
printf("%d\n",maxn);
top=0;
}
}