Topic links
I'm such a DP.
Thought for a while ... H1[i] Record the current maximum value (scroll array) of the tree I, h2[i] record the maximum height at I
These two arrays can be alternately updated
1#include <algorithm>2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <string>7#include <cmath>8#include <ctime>9#include <queue>Ten#include <stack> One#include <map> A#include <Set> - #defineRre (i,r,l) for (int i= (r); i>= (l); i--) - #defineRe (I,L,R) for (int i= (l); i<= (R); i++) the #defineClear (A, B) memset (A,b,sizeof (a)) - #defineInOut (x) printf ("%d", (x)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) + #defineLLin (x) scanf ("%lld", &x) - #defineOP operator + #defineCSC Main Atypedef unsignedLong LongULL; attypedefConst intCInt; -typedefLong LongLL; - using namespacestd; - voidInin (int&ret) - { -ret=0;intf=0;CharCh=GetChar (); in while(ch<'0'|| Ch>'9'){if(ch=='-') f=1; ch=GetChar ();} - while(ch>='0'&&ch<='9') ret*=Ten, ret+=ch-'0', ch=GetChar (); toret=f?-Ret:ret; + } - intn,a[2020][2020],h,delta,h1[4040],h2[4040]; the intMain () * { $ inin (n), Inin (h), Inin (delta);Panax NotoginsengRe (I,1, N) - { the intx,t;inin (x); + while(x--) Inin (t), a[i][t]++; A } theRre (I,h,1) + { -Re (J,1, N) H1[j]=max (H1[j],h2[i+delta]) +A[j][i]; $Re (J,1, N) h2[i]=Max (h2[i],h1[j]); $ } -printf"%d", h2[1]); - return 0; the}
bzoj1270 [BeijingWc2008] Leitao Kitten