Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

好像二分有问题, 我的是这样:

Posted by wrong123 at 2005-12-16 23:13:32 on Problem 2533
In Reply To:DP+二分查找,错哪了? Posted by:yiyiyi4321 at 2005-12-16 11:04:28
你里面的if有问题,另外我这总是可以保证j是D[1]到D[len]中
满足D[j]<A[i]的最大的一个


       else{                        //二分查找
                low = 1; high = len; j = 0;
                while(low<=high){
                    mid = (low + high)>>1;
                    if(D[mid]<A[i]&&D[mid+1]>=A[i]){j=mid;break;}
                    if(D[mid]<A[i]){
                        j=mid;
                        low = mid+1;
                    }
                    else {
                        high = mid-1; 
                    }         
                }                
                D[j+1]=A[i];              //更新
            }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator