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 |
63ms#include <cstdio> using namespace std; int n,loca,t; int a[100005],q[100005]; int Find(int l,int r,int x) { if(x<q[l])return l; if(q[l]==x)return l; if(q[r]==x)return r; if(r-l==1 && q[l]<x && x<q[r])return r; int mid=(l+r)/2; if(q[mid]<x)return Find(mid+1,r,x); else return Find(l,mid,x); } int main() { q[0]=-1000000; while(scanf("%d",&n)!=EOF && n) { t=0; for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=n;i++) { if(a[i]>q[t])q[++t]=a[i]; else { loca=Find(1,t,a[i]); q[loca]=a[i]; } } printf("%d\n",t); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator