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 |
为什么WA?麻烦看一下:#include <iostream> #include <fstream> using namespace std; int n; int a[30001]; int t[30001][2]; void main(){ ifstream cin("data.txt"); int testcase,i; cin>>testcase; while(testcase--){ cin>>n; for(i=0;i<n;i++){ cin>>a[i]; } if(n==1){ cout<<1<<endl; }else{ t[n-1][0]=1;t[n-1][1]=1; //t[n-1][1]代表后面的数比前面的小,t[n-1][0]代表比前面的大,从后往前递归 int max=0; for(i=n-2;i>=0;i--){ if(a[i]<a[i+1]){ t[i][1]=1; t[i][0]=1+t[i+1][1]; }else if(a[i]>a[i+1]){ t[i][0]=1; t[i][1]=t[i+1][0]+1; }else{ t[i][0]=t[i][1]=1; } if(t[i][1]>max)max=t[i][1]; } cout<<max<<endl; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator