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