HYSBZ 1010 Toy Packing Toy (decision monotone DP)

Source: Internet
Author: User

Test instructions

There are n toys, to be divided into groups, toys with the same width, but the length of C may be different . Give the order of n toys, any number of consecutive toys can become a group. The cost of the interval [i,j] becomes a group of cost= (J-i+sigma (Ck)-L) 2 and I<=k<=j. Given N and L and the length of each toy, what is the sum of the costs after the question is grouped? (n<=5*104).

Ideas:

Note: The cost is not a straight line function, the total length of each group + the number of toys closer to L better.

Transfer equation: Dp[i]=min (dp[j]+ (sum[i]-sum[j]+i-j+1-l) 2). Sum[i] Represents the sum of the length of the front I piece of toys, 0<j<i, (i-j+1) represents the number of toys in the same group as I.

According to the equation is possible to introduce this problem is to satisfy the decision Monotonicity. The following is a copy of the certificate, slightly modified:

Make f[i]=sum[i]+i, C=1+l, then dp[i]=min (dp[j]+ (f[i]-f[j]-c) 2)

1. proving monotonicity of decisions

Assuming that K decision at State i is superior to J decision, and J<k, then dp[k]+ (f[i]-f[k]-c) 2<=dp[j]+ (f[i]- DP[J]-C) 2.

And for a state T after I, set f[t]=f[i]+v, regardless of the V is how much.

To prove:dp[k]+ (f[t]-f[k]-c) 2<=dp[j]+ (f[t]-f[j]-c) 2

As long as the certificate ( f[t]=f[i]+v ):dp[k]+ (f[i]+v-f[k]-c) 2<=dp[j]+ (f[i]+v-f[j]-c) 2

As long as the card dp[k]+ (f[i]-f[k]-c) 2+2v* (f[i]-f[k]-c) +v2 <= dp[j]+ (f[i]-f[j]-c) 2+2v* (f[i]-f[j]-c) +v2.

As a hypothesis, so long as the certificate: 2v* (f[i]-f[k]-c) <=2v* (f[i]-f[j]-c).

Certificate:f[k]>=f[j](obviously)

Proof complete.

HYSBZ 1010 Toy Packing Toy (decision monotone DP)

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.