Report on solving problems in stacked boxes

Source: Internet
Author: User

Longest ascending subsequence with weighted values
F[i] means that the minimum weight of the stacked I box is discussed from the back forward (because it is the inverse read, actually from the go after discussion, more like the longest ascending subsequence)

Motion regulation equation: f[k+1]=mid (f[k+1], self[i]+f[k]) (Stand[i]>=f[k]) (0<=k<i)
Equation of the longest ascending subsequence f[i]=f[j]+1(1<=j<i, a[j]<a[i])

Again, the same algorithm error as the longest ascending sub-sequence.
Once again, the f[1] was given an initial value and then discussed from F[2],
OK, from the f[2] discussion, but only from the back to the discussion of f[1], really afraid of WA.
And the interceptor missile is the same as wrong, and the chorus formation is the same as wrong, and archery as wrong as the outside focus of tender, and rectangular set of rectangles as wrong ...
Because the first missile does not have to be called out, because the longest ascending subsequence does not necessarily have to start with the first number.
This pile of questions are unknown. The dynamic planning type of the entry, the answer structure does not necessarily contain the first number.

1#include <stdio.h>2 #defineMAXN 10013 #defineINF 100000004 intMinintAintb)5 {6     if(A&LT;B)returnA;7     returnb;8 }9 intSELF[MAXN], STAND[MAXN], F[MAXN];Ten intMain () One { A     intN, I, K; -scanf"%d", &n); -      for(I=n; i>=1; i--) scanf ("%d%d", &self[i], &stand[i]);//reverse read-in thef[1]=self[1]; -      for(i=2; i<=n; i++) -          for(F[i]=inf, k=i-1; k>=1; k--) -             if(Stand[i]>=f[k]) f[k+1]=min (f[k+1], self[i]+f[k]);//decisions like longest ascending sub-sequences if (A[j]<a[i]) f[i]=f[j]+1 (1<=j<i) +      for(I=n; i>=1&&f[i]==inf; i--); -printf"%d", i); +     return 0; A}
here is the error code, listen to the WA sound a piece
1#include <stdio.h>2 #defineMAXN 10013 #defineINF 100000004 intMinintAintb)5 {6     if(A&LT;B)returnA;7     returnb;8 }9 intSELF[MAXN], STAND[MAXN], F[MAXN];Ten intMain () One { A     intN, I, K; -scanf"%d", &n); -      for(I=n; i>=1; i--) scanf ("%d%d", &self[i], &stand[i]); the      for(i=1; i<=n; i++) -          for(F[i]=inf, k=i-1; k>=0; k--) -             if(stand[i]>=F[k]) -f[k+1]=min (f[k+1], self[i]+f[k]); +      for(I=n; i>=1&&f[i]==inf; i--); -printf"%d", i); +     return 0; A}
The following is the correct code

Report on solving problems in stacked boxes

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.