迭代器只能用++或者–, 不能+1或者-1
L3-2 宠物收养场
利用set查询和x最近的元素
set<int> se
set自带的lower_bound比通用的效率更高
即 se.lower_bound(x) 速度比 lower_bound(se.begin(), se.end(), x) 更快
查询和x最近的元素(无重复)只需要让
auto t = se.lower_bound(x),
auto t2 = t;
auto t3 = --t;
t = t2;//因为t自减了一次
比较abs(*t - x) 和 abs(*t3 - x)即可
set和map从小到大
priorty_queue从大到小
都需要greater<>来改变
优先队列还需vector<>参数在前面