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 <algorithm> #include<queue> #include<stack> #define max(a,b) a>b?a:b using namespace std; int ans=1; int num; int numall[10001]; void lcs(int a[],int n){ stack<int>s; s.push(a[0]); int length=1; int last=a[0]; for(int i=1;i<n;i++){ if(a[i]>last){ s.push(a[i]); length++; last=a[i]; } else if(a[i]<last){ ans=max(ans,length); while(a[i]<last&&!s.empty()){ length--; s.pop(); last=s.top(); } s.push(a[i]); length++; } } } int main(){ while(cin>>num){ ans=1; int i=0; while(i<num)scanf("%d",&numall[i++]); lcs(numall,num); printf("%d\n",ans); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator