| ||||||||||
| 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 | |||||||||
高手帮忙看看算法错在哪里#include <iostream>
using namespace std;
long sti[50001];
long low[50001];
int main()
{
long i,n;
while(cin>>n)
{
cin>>sti[1];
low[1]=1;
for(i=2;i<=n;i++)
{
cin>>sti[i];
low[i]=i;
while(low[i]>=2&&sti[i]>sti[low[i]-1]&&sti[low[i]]>sti[low[low[i]-1]])
low[i]=low[low[i]-1];
}
long max=0;
for(i=1;i<=n;i++)
if(i-low[i]>max) max=i-low[i];
if(max) cout<<max<<endl;
else cout<<"-1"<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator