STL党入
查看原帖
STL党入
361932
exCat楼主2023/7/20 16:39

如果你用了 STLSTL 的二分查找函数,而不是手写,一定注意 lowerlower _ boundbound 和upperupper _ boundbound 的区别。 求最长不下降子序列时,应该用 upperupper _ boundbound

for(int i=n-1;i>=1;i--)
{
	if(a[i]>=b[mx])b[++mx]=a[i];//注意等号
	else
	{
		int j=upper_bound(b+1,b+mx+1,a[i])-b;
		b[j]=a[i];
	}
}

求导弹系统个数,应用 lowerlower _ boundbound

int j=lower_bound(jg+1,jg+cnt+1,x)-jg;
if(j>cnt)
{
	cnt++;
	jg[cnt]=x;
}
else jg[j]=x;
2023/7/20 16:39
加载中...