http://115.28.138.223:81/view.page?opid=3
统计出连续的最长乘以当前高度,找最大即可
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define within(x,a,b) ((unsigned)((x)-(a))<=((b)-(a)))
using namespace std;
int readint(int *p)
{
int ch;
while(!within(ch=getchar(),'',''))
if(ch == EOF) return EOF;
int rslt = ;
do
rslt=rslt*+(ch-'');
while(within(ch=getchar(),'',''));
*p = rslt;
return ;
}
void out(int a)
{
if(a>)
out(a/);
putchar(a%+'');
}
int a[];
int main()
{
int x;
while(cin>>x)
{
memset(a,,sizeof(a));
int floor=,max=,maxfloor=,looop=,MAXS=;
for(int i=;i<x;i++)
{
readint(&a[i]);
if(a[i]>maxfloor) {maxfloor=a[i];}
}
while(floor<=maxfloor)
{
for(int i=;i<x;i++)
{
if(a[i]>=floor)
{
looop++;
}
else if(a[i]<floor)
{
if(looop>max) max=looop;
looop=;
}
if(looop>max) max=looop;
}
int yy=max*floor;
if(yy>MAXS) MAXS=yy;
floor++;
looop=;
max=;
}
out(MAXS);
cout<<endl;
}
return ;
}