摘要: 思路:直接通过斜率优化进行求解。#include#include#include#include#include#define Maxn 1000010using namespace std;__int64 sum[Maxn];__int64 num[Maxn];int que[Maxn*4];int main(){ int n,k,head,rear,x; int i,j; double ans; while(scanf("%d%d",&n,&k)!=EOF){ ans=0; for(i=1;i=(sum[i]-sum[que[head]]... 阅读全文
posted @ 2013-10-14 21:36 fangguo 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 思路:很普通的斜率dp#include#include#include#include#define Maxn 10010#define LL intusing namespace std;LL dp[Maxn][2],num[Maxn];int que[Maxn*10];inline LL getleft(int x,int j,int k){ return dp[j][x]+num[j+1]*num[j+1]-(dp[k][x]+num[k+1]*num[k+1]);}inline LL getright(int j,int k){ return 2*(num[j+1]-num... 阅读全文
posted @ 2013-10-14 21:34 fangguo 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 思路:dp[i]=dp[j]+(sum[i]-sum[j])^2+m;剩下的就是普通斜率dp做法。#include#include#include#include#include#define Maxn 500010#define LL __int64using namespace std;LL dp[Maxn],num[Maxn],sum[Maxn];int que[Maxn*2];LL getleft(int j,int k){ return dp[j]+sum[j]*sum[j]-(dp[k]+sum[k]*sum[k]);}LL getright(int j,int k){ ... 阅读全文
posted @ 2013-10-14 10:27 fangguo 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 思路: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#include#include#include#include#define Maxn 1010#define LL __int64using namespace std;LL dp[Maxn][Maxn],num[Maxn],sum[Maxn],val[Maxn];int que[Maxn*10];LL getleft(int x,int j,int k){ return ... 阅读全文
posted @ 2013-10-14 09:52 fangguo 阅读(163) 评论(0) 推荐(0) 编辑