数据离散化

vector<int>v;
void init(){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
int getid(int x){
    return lower_bound(v.begin(),v.end(),x)-v.begin()+1;
}
原文地址:https://www.cnblogs.com/yesuweiYYYY/p/13809484.html