#include<bits/stdc++.h>
using namespace std;
int Binary_Search(int a[],int n,int k)//常规二分
{
int l=0,r=n-1,mid;
while(l<=r)
{
mid=(l+r)/2;
if(a[mid]==k)return mid;
else if(a[mid]>k) r=mid-1;
else l=mid+1;
}
return -1;
}
int Binary_Search2(int a[],int n,int k)//含相同值的情况下返回最左边下标
{
int l=0,r=n-1,mid;
while(l<r)
{
mid=(l+r)/2;
if(a[mid]==k)r=mid;
else if(a[mid]>k) r=mid-1;
else l=mid+1;
}
if(a[l]==k)return l;
else return -1;
}
int main()
{
int a[5]={0,1,1,2,5};
int i,j;
cout<<Binary_Search2(a,5,0)<<endl;
}