[BeijingWc2008] [BZOJ1270] Leitao kitten | Dynamic planning

Source: Internet
Author: User

1270: [BeijingWc2008] Leitao kitten time limit:50 Sec Memory limit:162 MB
submit:1002 solved:481
[Submit] [Status] [Discuss] Description Inputoutputsample InputSample Output8HINT

Source

Alas...... The first time I wrote a hyper-violent DP ran through 50s.

The F1,F2 represents the maximum height of I, respectively, and the current height is the maximum value on the first tree.

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<cmath>using namespacestd;intn,h,mx,delta,a[2005][2005],f1[5005],f2[5005];inlineintRead () {intA=0, f=1;CharC=GetChar ();  while(c<'0'|| C>'9') {if(c=='-') f=-1; C=GetChar ();}  while(c>='0'&&c<='9') {a=a*Ten+c-'0'; C=GetChar ();} returnA *F;}intMain () {n=read (); H=read (); Delta=read ();  for(intI=1; i<=n;i++)    {        intx=read ();  while(x--)        {            intj=read (); A[I][J]++; }    }     for(intI=h;i>0; i--)    {        intt= (i+delta<=h) F1[i+delta]:0;  for(intj=1; j<=n;j++) {F2[j]=max (f2[j],t) +A[j][i]; F1[i]=Max (f1[i],f2[j]); }} printf ("%d", f1[1]); return 0;}

[BeijingWc2008] [BZOJ1270] Leitao kitten | Dynamic planning

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.