Codevs 50,591 to play CS

Source: Internet
Author: User

/*Space 32000 I wrote it all 31900+ drunk can reduce dimensional optimization space of the lazy wrote the state: F[i][j] The former I topic a altogether did J minute B The least do the problem time shift: Consider each topic to who do f[i][j] = min (f[i-1][j-a]a do, f[ I-1][j]+b b); Finally, the question Time of F[n] enumeration A is updated with the answer*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 201using namespacestd;intn,a,b,sum,ans=0x3f3f3f3f, f[maxn][maxn*MAXN];intMain () {scanf ("%d",&N); Memset (F,127/3,sizeof(f)); f[0][0]=0;  for(intI=1; i<=n;i++) {scanf ("%d%d", &a,&b); sum+=b; f[i][0]=sum;  for(intj=0; j<=40000; j + +)          if(j>=a) F[i][j]=min (f[i-1][j-a],f[i-1][j]+b); Elsef[i][j]=f[i-1][j]+b; }           for(intI=1; i<=40000; i++) ans=min (Ans,max (i,f[n][i)); printf ("%d\n", ans); return 0;}

Codevs 50,591 to play CS

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.