标签:code www 单调队列 lan https 队列 math amp ref
优化形如\(f_i=min/max(f_i,f_j+val_i)(l_i\leqslant j\leqslant r_i)\) 的\(DP\)方程
如瑰丽华尔兹中\(DP\)方程为\(f_{i,j}=max(f_{i,j},f_{i-dx_,j-dy}+dis_{i,j,i-dx_,j-dy})\)
\(code:\)
while(h<=t&&f[x][y]>q[t].val+dis(x,y,q[t].x,q[t].y)) t--;
q[++t]=(que){f[x][y],x,y};
while(h<=t&&(abs(x-q[h].x)>len||abs(y-q[h].y)>len)) h++;
f[x][y]=max(f[x][y],q[h].val+dis(x,y,q[h].x,q[h].y));
ans=max(ans,f[x][y]);
标签:code www 单调队列 lan https 队列 math amp ref
原文地址:https://www.cnblogs.com/lhm-/p/12229623.html