1296: [SCOI2009] Painter

Source: Internet
Author: User

1296: [SCOI2009] painter time limit: ten Sec Memory Limit: 162 MB
Submit: 916 Solved: 532
[Submit] [Status] Descriptionwindy have N planks to be painted. Each plank is divided into M-squares. Each grid is to be painted red or blue. Windy every time you paint, you can select a continuous lattice on a board and apply a color. Each lattice can only be painted once. If windy can only paint T-times, how many squares can he paint correctly? A lattice if not painted or painted in the wrong color, even if the wrong paint. Input file paint.in The first line contains three integers, N M T. Next there are n rows, one string of length m for each line, ' 0 ' for Red, ' 1 ' for blue. Output file Paint.out contains an integer, up to the correct number of squares to be whitewashed. Sample Input3 6 3
111111
000000
001100
Sample Output16
HINT

30% of the data, meet 1 <= n,m <=, 0 <= T <= 100.
100% of the data, meet 1 <= n,m <=, 0 <= T <= 2500.

Source

Day2

The puzzle: This ... Once again the sense of heaven and land did not commit the brain residue (phile: ... ), good idea--first through DP and then find out for each layer above the condition-that is, for the first I units, Brush J times can get how much area, then directly used to play knapsack problem, group backpack Oh ... See "Backpack Ninth Lecture" (portal)

1var
2N,m,t,ll,i,j,k,l,a1:longint;
3A:Array[0.. -] ofLongint;
4B,c:Array[0.. -,0..10000] ofLongint;
5C1:char;
6functionMax (x,y:longint): Longint;inline;
7begin
8 ifX>y ThenMax:=xElseMax:=y;
9End;
TenfunctionMin (x,y:longint): Longint;inline;
Onebegin
AifX<y ThenMin:=xElseMin:=y;
-End;
-begin
theREADLN (n,m,t);
- fori:=1 toN Do
-begin
- forj:=1 toM Do
+begin
-Read (C1);
+a[j]:=a[j-1]+ord (C1)- -;
A End;
atREADLN;
- forj:=1 toM Do
- fork:=1 toM Do
-begin
-b[k,j]:=0;
- forl:=0 toK-1 Do
inbegin
-A1:=A[K]-A[L];
toB[k,j]:=max (b[k,j],b[l,j-1]+max (A1,K-L-A1))
+ End;
-End;
the forj:=1 toT Do
* begin
$A1:=min (M,J);
Panax Notoginseng fork:=1 toA1 Do
-C[i,j]:=max (c[i,j],c[i-1, J-k]+b[m,k]);
theEnd;
+End;
A fori:=1 toT Do
theLl:=max (Ll,c[n,i]);
+Writeln (LL);

-      End.

1296: [SCOI2009] Painter

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.