Topic links
Backpack
Two-layer Backpack (group backpack)
A situation in which a piece of the board is handled
A situation that deals with the whole
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)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) - #defineLLin (x) scanf ("%lld", &x) + #defineInin (x) scanf ("%d", &x) - #defineCSC Main +typedef unsignedLong LongULL; AtypedefConst intCInt; attypedefLong LongLL; - using namespacestd; - intYP () - { - intx=0, f=0;CharCh=GetChar (); - while(ch<'0'|| Ch>'9'){if(ch=='-') f=1; ch=GetChar ();} in while(ch>='0'&&ch<='9') x*=Ten, x+=ch-'0', ch=GetChar (); - returnf?-x:x; to } + intn,m,t,ans,a[ -],h[ -][ -],hh[ -][2525]; - Chars[ -]; the intCSC () * { $N=yp (), M=yp (), t=YP ();Panax NotoginsengRe (I,1, N) - { theStrin (s+1); +Re (J,1, m) a[j]=s[j]-'0'+a[j-1]; ARe (J,1, m) Re (k,1, M) the { +h[k][j]=0; -Re (L,0, K-1) $ { $ inttemp=a[k]-A[l]; -H[k][j]=max (h[k][j],h[l][j-1]+max (temp,k-l-temp)); - } the } -Re (J,1, T) Re (k,1, Min (m,j))WuyiHh[i][j]=max (hh[i][j],hh[i-1][j-k]+h[m][k]); the } -Re (I,1, T) ans=Max (ans,hh[n][i]); Wuprintf"%d\n", ans); - return 0; About}
bzoj1296 [SCOI2009] Painter