离散化

  1. 排序
  2. 去重
  3. 二分查找获取下标
vector<int> discretization(vector<int> &a) {
	vector<int> alls(a);
	sort(alls.begin(), alls.end()); // 排序
	alls.erase(unique(alls.begin(), alls.end()), alls.end()); //去重
	for (int &x : a) { //重新赋值原数组
 		x = lower_bound(alls.begin(), alls.end(), x) - alls.begin();
	}
	return alls; //用于查表
}