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 |
看着题顺手一编,1次AC!#include <iostream> using namespace std; int main() { long n; while(cin>>n) { long a[n]; for(int i=0;i<n;++i) cin>>a[i]; long max=-1,now=0; for(long i=0;i<n-1;) { now=0; for(long j=i+1;j<n;++j) { if(a[i]>a[j]){++i;break;} else if(a[i]<a[j]) { while(j<n&&a[i]<a[j]) {++j;++now;} --j; while(j>i+1) { long l; for(l=i+1;l<j;++l) { if(a[l]>a[j]) {now--;j--;break;} } if(l==j)break; } i=j; } } if(max<now)max=now; } if(max==0)max=-1; cout<<max<<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