Bzoj 1296 scoi2009 dynamic Planner

Source: Internet
Author: User

For a given n * m board, each vertex needs to be flushed into one or two colors. Each vertex can only be flushed for a row in a row, and only one vertex can be flushed once, find the maximum number of T-paint brush points

First, the processing order for each line is f [I] [J]. To use the I brush to brush the first J grids, the maximum number of vertices can be brushed. the number of points and then group the backpack.

# Include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # define M 60 using namespace STD; int n, m, T, f [m] [m]; // F [I] [J] indicates the maximum number of grids that can be flushed out with the I brush. // F [I] [J] = max {f [I-1] [k] + max (CNT [0], CNT [1])} // (I-1 <= k <= J-1) Char s [m]; int A [m] [m]; // A [I] [J] indicates the maximum value of void dp (int pos) {int I, j, k; memset (F, 0xef, sizeof F); F [0] [0] = 0; for (I = 1; I <= m; I ++) {for (j = I; j <= m; j ++) {int CNT [2] = {0}; For (k = J-1; k> = I-1; k --) {CNT [s [k + 1]-'0'] ++; F [I] [J] = max (F [I] [J], f [I-1] [k] + max (CNT [0], CNT [1]) ;}}for (I = 1; I <= m; I ++) A [POS] [I] = f [I] [m];} int packet_backpack () {int I, J, K; static int G [m] [M * m]; memset (G, 0xef, sizeof g); G [0] [0] = 0; for (I = 1; I <= N; I ++) for (j = 0; j <= m; j ++) for (k = T; k> = J; k --) G [I] [k] = max (G [I] [K], G [I-1] [k-J] + A [I] [J]); return G [N] [T];} int main () {int I; CIN> N> m> T; for (I = 1; I <= N; I ++) {scanf ("% s", S + 1); DP (I) ;}cout <packet_backpack () <Endl ;}


Bzoj 1296 scoi2009 dynamic Planner

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.