Serie A champions:
Some trees are high given. One operation: Increase the height of a tree by H and spend it as h*h.
After the operation is complete, the two trees spend a height difference * Fixed value C.
Ask for a two-flower fee plus and a minimum value.
Exercises
Very much like NOIP2014 d1t3.
The violent movement is O (1*10^9) t
So a monotone queue, each tree sweep two times the end.
Well, look at the water code.
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 101000# Define M 105#define inf 0x3f3f3f3fusing namespace Std;int f[2][m],g[2][m],n,c;int now,last;int h[n];int Main () {//freopen ("Test.in", "R", stdin), int i,j,k;scanf ("%d%d", &n,&c), for (i=1;i<=n;i++) scanf ("%d", &h[i]); Now=0, Last=1;for (i=1;i<=n;i++) {now^=1,last^=1;int temp=inf;for (j=100;j>=h[i];j--) {temp=min (temp+c,f[last][j]); f [Now] [J]=temp+ (J-h[i]) * (J-h[i]);} Temp=inf;for (j=1;j<=100;j++) {temp=min (temp+c,f[last][j]), F[now][j]=min (f[now][j],temp+ (J-h[i]) * (J-h[i])); (J
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
"POJ3612" "Usaco 1.Telephone wire Dynamic adjustment