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 |
Why wa?Help!!!Why wa?Help!!! #include<iostream> using namespace std; int main() { unsigned m,n,i; cin>>m; unsigned a[30040]; while(m--){ cin>>n; for(i=0;i<n;i++) { cin>>a[i]; } unsigned j,max=1,t,s; if(n==1) cout<<1<<endl; else{ for(i=0;i<n-1;i++) { t=1,s=-1; if(a[i] > a[i+1]) { s = 1; t ++; for(j=i+1;j<n-1;j++) { if( s==1&&a[j]<a[j+1] || s==-1&&a[j]>a[j+1] ) { t ++; s*= -1; } else break; } if(t > max) max = t; } } cout<<max<<endl; } } return 0; } lp!!! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator