好玄学(?
查看原帖
好玄学(?
1379399
reductt楼主2024/11/26 20:24

rt,思路是第一篇的思路。

如果把

	FOR(i,1,n){
		if(!lst[a[i]])f[i]=f[i-1];
		else f[i]=f[i-1],f[i]=max(f[i],f[lst[a[i]]+1]+got(lst[a[i]]+1,i-1)+a[i]);
		lst[a[i]]=i;
	}

写成

	FOR(i,1,n){
		if(!lst[a[i]])f[i]=f[i-1];
		else f[i]=max(f[i-1],f[lst[a[i]]+1]+got(lst[a[i]]+1,i-1)+a[i]);
		lst[a[i]]=i;
	}

就过不去第二个大样例,保证代码其他部分是一样的,这是为什么

2024/11/26 20:24
加载中...