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:AC 了 110ms~In Reply To:AC 了 110ms~ Posted by:810974380 at 2009-08-25 15:54:46 我的代码,390ms #include <iostream> #include <cstring> #include <fstream> using namespace std; int p[40000],a[40000],n,len; void binary_search(int k) { int left=1,right=len,mid=0; while(left<=right) 因为开始这里条件写成了while(left!=left),出现了 left=1,right=0 的情况,死循环,狂TLE>_<…… 欲哭无泪…… { mid=(right+left)/2; if(k>a[mid]) left=mid+1; else right=mid-1; } if(a[left]>k) a[left]=k; else a[left+1]=k; } int main() { int t; cin>>t; while(t--) { cin>>n; for(int i=1;i<=n;i++) cin>>p[i]; memset(a,0,sizeof(a)); len=1; a[1]=p[1]; for(int i=2;i<=n;i++) { if(p[i]<a[len]) { binary_search(p[i]); } else { len++; a[len]=p[i]; } } cout<<len<<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