求助
查看原帖
求助
778011
DreamLand_zcb楼主2023/6/7 17:09

为啥在计算 MIN_SORT_GAP 的时候要这样

void get_MSG(int x)
{
	multiset<int>::iterator it = b.lower_bound(x);
	int w = *it - x;
	it--;
	w = min(w, x - *it);
	MSG = min(MSG, w);
	b.insert(x);
}

而不能这样

void get_MSG(int x)
{
	multiset<int>::iterator it = b.lower_bound(x);
	MSG = min(MSG, min(abs(*it - x), abs(x - *(--it))));
	b.insert(x);
}
2023/6/7 17:09
加载中...