题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2490 Parade Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 902 Accepted Submission(s): 396 Problem Description Panagola, The Lord of city F lik…
Mice and Holes 单调队列优化dp n个老鼠,m个洞,告诉你他们的一维坐标和m个洞的容量限制,问最小总距离.1 ≤ n, m ≤ 5000. 首先列出朴素的dp方程:\(f[i][j]=min(f[i-1][k]+s[j]-s[k])\),其中\(f[i][j]\)表示前i个洞,有j个老鼠进洞.s[j]-s[k]表示第k+1到j个老鼠进洞的路径和.然后我们发现,\(f[i][j]\)的值取决于最小的\(f[i-1][k]-s[k]\ (k<=j)\),同时,j-k必须小于等于第i…