摘要: 很裸的一道单调队列题(把数列扩大一倍即可),但是要注意题目的比较条件(定义比较函数),不然会WA代码:#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;const int N=100010;typedef pair<int,int> PII;int T,n,... 阅读全文
posted @ 2012-08-28 23:22 编程菜菜 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 斜率优化DP:未优化方程:dp[i]=dp[j]+C+(a[i]-a[j+1])^2;解法同HDU3507Trick: 检查斜率时不能用叉乘 直接检查即可(不然数字范围过大超long long会WA)代码:#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <math.h>usin... 阅读全文
posted @ 2012-08-28 23:16 编程菜菜 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 斜率优化DP入门题O(n^2)方程: dp[i]=dp[j]+M+(sum[i]-sum[j])^2;用斜率优化掉枚举j的O(n)代码(含输入输出外挂):#include <iostream>#include <stdio.h>#include <string.h>using namespace std;const int N=500010;typedef long long LL;#define... 阅读全文
posted @ 2012-08-28 23:16 编程菜菜 阅读(132) 评论(0) 推荐(0) 编辑