1270: [BeijingWc2008] Leitao kitten time limit:50 Sec Memory limit:162 MB
[Submit] [Status] [Discuss] Description Inputoutputsample InputSample Output8HINT
Idea: Save the max value of I+z; the DP value of the previous line;
#include <bits/stdc++.h>using namespacestd;#definell __int64#defineMoD 100000007#defineESP 0.00000000001Const intn=5e3+Ten, m=1e6+Ten, inf=1e9;intA[n][n];intDp[n];intPre[n];intMaxx[n];voidinit () {memset (DP,0,sizeof(DP)); Memset (A,0,sizeof(a)); memset (PRE,0,sizeof(pre)); Memset (Maxx,0,sizeof(Maxx));}intMain () {intx,y,z,i,t; while(~SCANF ("%d%d%d",&x,&y,&z)) {init (); for(i=1; i<=x;i++) {scanf ("%d",&t); for(intj=0; j<t;j++) { intv; scanf ("%d",&v); A[v][i]++; } } for(i=y;i>=1; i--) { for(t=1; t<=x;t++) {Dp[t]=max (Maxx[i+z],pre[t]) +A[i][t]; Pre[t]=Dp[t]; Maxx[i]=Max (maxx[i],dp[t]); } for(t=1; t<=x;t++) {printf ("%d", dp[t]); } cout<<endl<<Endl; } intans=0; for(i=1; i<=x;i++) ans=Max (ans,dp[i]); printf ("%d\n", ans); } return 0;}/*3 1 4 106 3 5 9 7 8 4 5 3 6 9*/
Bzoj 1270: [BeijingWc2008] Leitao kitten simple dp+ Scrolling array