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 |
Re:嘿嘿,用时一样In Reply To:AC 了 110ms~ Posted by:810974380 at 2009-08-25 15:54:46 之前做过一个一样的题,改一下就过了…… 贴代码: #include<iostream> #include<stdio.h> using namespace std; int a[400001],dp[400001]; int main() { int m; scanf("%d",&m); while(m--) { int num1=1; int i; int n; scanf("%d",&n); int max; int p,r; for(i=1;i<=n;i++) { scanf("%d",&r); a[i]=r; } dp[1]=a[1]; max=1; int low,hight,mid; for(i=2; i<=n; i++) { low=0; hight=max; while(low<=hight) { mid=(low+hight)/2; if(a[i]>dp[mid]) low=mid+1; else hight=mid-1; } dp[low]=a[i]; if(low>max) max++; } int num=max; cout<<num<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator