二分模板

while(L<=R)
{
   mid=(L+R)/2;
   if(ok(mid)) ans=mid,L=mid+1;
   else R=mid-1;
}

  

原文地址:https://www.cnblogs.com/adelalove/p/8683892.html