hdu 3669(斜率优化DP)】的更多相关文章

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…
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…
题意: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]=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…
思路 : 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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 题目大意:给定一个长度为n(最长为10^5)的正整数序列,求出连续的最短为k的子序列平均值的最大值. Sample Input 10 6 6 4 2 10 3 8 5 9 4 1   Sample Output 6.50 分析:斜率优化DP,要认真看 代码如下: # include<iostream> # include<cstdio> # include<cstring&…
题目链接:hdu 2829 Lawrence 题意: 在一条直线型的铁路上,每个站点有各自的权重num[i],每一段铁路(边)的权重(题目上说是战略价值什么的好像)是能经过这条边的所有站点的乘积之和..然后给你m个炮弹,让你选择破坏掉m段铁路,使剩下的整条铁路的战略价值最小. 题解: 和hdu 3480 Division(斜率优化DP)这题相同,只是方程不同而已,改改就行了. #include<bits/stdc++.h> #define F(i,a,b) for(int i=a;i<=…