| ||||||||||
| 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 | |||||||||
好像二分有问题, 我的是这样: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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator