| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
维护一个不减的栈…… top=0; stack[ top ]=-100; ans=0ll;
for( int i=1; i<=N+1 ; i++){
if( i<=N )
h=getlonglong(); // 手写的读入,又快又安全
else h=-1;
if( h>=stack[ top ] ) stack[ ++top ]=h,len[ top ]=1;
else{
long long j=0;
while( stack[ top ]>h ){
j+=len[ top ];
ans=max( ans , j*(long long)stack[ top ] );
top--;
}
stack[ ++top ]=h;
len[ top ]=j+1;
}
}
cout << ans << endl;
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator