Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

看着题顺手一编,1次AC!

Posted by jackch at 2006-10-01 16:11:33 on Problem 2452
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator