B - Lawrence HDU - 2829 这个题目我觉得很难,难在这个dp方程不会写. 看了网上的题解,看了很久才理解这个dp转移方程 dp[i][j] 表示前面1~j 位并且以 j 结尾分成了 i 段的最小权值和 再定义一个数组 w[a,b] 表示 a到b 的权值和,注意这个不是前缀和,而是题目给的那种权值和 比如 a 到 b  是4 5 1 2 Its Strategic Value is 4*5 + 4*1 + 4*2 + 5*1 + 5*2 + 1*2 = 49. w[a,b]=4…
题意:n个数之间放m个障碍,分隔成m+1段.对于每段两两数相乘再求和,然后把这m+1个值加起来,让这个值最小. 设: d(i, j)表示前i个数之间放j个炸弹能得到的最小值 sum(i)为前缀和,cost(i)为前i个数两两相乘之和. 则有状态转移方程: 设0 ≤ l < k < i,且k比l更优,有不等式: 整理得到,注意不等号方向: 最后变成了斜率的形式,下面就用一个队列维护即可. #include <iostream> #include <cstdio> #inc…
思路:dp[i][x]=dp[j][x-1]+val[i]-val[j]-sum[j]*sum[i]+sum[j]*sum[j]; 其中val[i]表示1~~i是一段的权值. 然后就是普通斜率dp做法. #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cstring> #define Maxn 1010 #define LL __…
Covered Walkway Time Limit: 30000/10000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1496    Accepted Submission(s): 602 Problem Description Your university wants to build a new walkway, and they want at least p…
思路:dp[i]=dp[j]+sum[i]-sum[j]-(i-j)*num[j+1]; 然后就是比较斜率. 注意的时这里j+t<=i: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define Maxn 400010 #define LL __int64 using namespace std; LL…
Cross the Wall Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others)Total Submission(s): 4479    Accepted Submission(s): 812 Problem Description “Across the Great Wall, we can reach every corner in the world!” Now the…
思路 : 1,用一个单调队列来维护解集. 2,假设队列中从头到尾已经有元素a b c.那么当d要入队的时候,我们维护队列的下凸性质, 即如果g[d,c]<g[c,b],那么就将c点删除.直到找到g[d,x]>=g[x,y]为止,并将d点加入在该位置中. 3,求解时候,从队头开始,如果已有元素a b c,当i点要求解时,如果g[b,a]<sum[i], 那么说明b点比a点更优,a点可以排除,于是a出队.最后dp[i]=getDp(q[head]). #include<bits/std…
Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 11141    Accepted Submission(s): 3393 Problem Description Zero has an old printer that doesn't work well sometimes. As it is antiqu…
Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 12185    Accepted Submission(s): 3733 Problem Description Zero has an old printer that doesn't work well sometimes. As it is antiqu…
在kuangbin巨巨博客上学的. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; + ; int d[maxn], Q[maxn], sum[maxn]; int head, tail; int n, M; int inline dx(int i, int j) { return sum[j] - sum[i…