poj2392 Stone--Sort after backpack

Source: Internet
Author: User

Topic:

First, by limiting the height from small to large sort, will not affect the feasible solution, but not the sorting may be the correct situation;

When scrolling an array with%2, be sure to pay attention to each copy of the situation, because this WA several times.

The code is as follows:

#include <iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespacestd;intk,mx;BOOLf[3][400005];structn{intH,a,c;} p[405];BOOLCMP (N x,n y) {returnx.a<y.a;}intMain () {scanf ("%d",&k);  for(intI=1; i<=k;i++) scanf ("%d%d%d", &p[i].h,&p[i].a,&p[i].c), mx+=p[i].h*p[i].c; Sort (P+1, p+k+1, CMP); f[0][0]=1;  for(intI=1; i<=k;i++) {memcpy (f[i%2],f[(I-1)%2],sizeoff[(I-1)%2]);//!!!         for(intj=p[i].h;j<=p[i].a;j++)             for(intL=0; l<=p[i].c&&j-l*p[i].h>=0; l++)                if(F[(i1)%2][j-l*p[i].h]) f[i%2][j]=1; }     for(intj=mx;j>=0; j--)        if(f[k%2][j]) {printf ("%d", J); return 0; }}

poj2392 Stone--Sort after backpack

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.