二分函数
sort(a+1,a+n+1);//排序
int it=lower_bound(a+1,a+n+1,x)-a;//要在a[1]~a[n]里找第一个大于等于x的位置
int it=upper_bound(a+1,a+n+1,x)-a;//upper_bound找的是第一个严格大于x的位置
int it=lower_bound(a+1,a+n+1,x);cout<<*it;//要在a[1]~a[n]里找第一个大于等于x的值
//在使用lower_bound和upper_bound都需要保证容器有序(从小到大排列)
vector<int>G;//构造一个叫G的容器
G.push_back(2);
sort(G.begin(),G.end());
auto it=lower_bound(G.begin(),G.end(),x);//用法同上