"POJ3612" "Usaco-Nov Gold" 1.Telephone wire dynamic adjustment

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.