|
|
back to boardwhat is test case 6? Posted by demo 21 Dec 2008 08:45 I got too many wa on it.. Re: what is test case 6? Posted by demo 21 Dec 2008 09:18 got it Re: what is test case 6? I got WA, too. Can you tell me this case ? Re: what is test case 6? Got it. Here is the case that helped me: 9998 -20000 0 0 Result: (x)(x)(x-2)(x+10000) Edited by author 23.12.2008 13:51 Re: what is test case 6? #include<iostream.h> int max1(int *x,int *y,int i,int j) { int k,m1=0,r=-1;bool p=true; for(k=i+1;k<=j&&p&&r==-1;k++) if(x[k]>=x[i]) { m1=y[k]; r=k; p=false; } if(r!=-1){ for(k=r;k<=j;k++) if(x[k]>=x[i] && y[k]>=m1) m1=y[k];
return m1+1; } return -1; } int main() { int n,a[1005],i,l[1005],max; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; l[n]=1; if(a[n-1]>a[n]) l[n-1]=1; else l[n-1]=2; for(i=n-2;i>=1;i--) l[i]=max1(a,l,i,n); max=l[1]; for(i=2;i<=n;i++) if(l[i]>max) max=l[i]; cout<<max; return 0; } |
|
|