#P4158. [SCOI2009] 粉刷匠

    ID: 3091 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp递推2009四川各省省选枚举,暴力背包

[SCOI2009] 粉刷匠

Description

windy has NN wooden boards that need to be painted. Each board is divided into MM cells. Each cell should be painted red or blue.

In each painting operation, windy can choose a contiguous segment of cells on a single board and paint it with one color. Each cell can be painted at most once.

If windy can paint at most TT times, what is the maximum number of cells he can paint correctly?

A cell is considered incorrect if it is left unpainted or painted with the wrong color.

Input Format

The first line contains three integers, NN, MM, TT.

Then there are NN lines, each containing a string of length MM, where 0 denotes red and 1 denotes blue.

Output Format

Output a single integer: the maximum number of cells that can be painted correctly.

3 6 3
111111
000000
001100
16

Hint

For 30%30\% of the testdata, 1N,M101 \le N, M \le 10, 0T1000 \le T \le 100.

For 100%100\% of the testdata, 1N,M501 \le N, M \le 50, 0T25000 \le T \le 2500.

Translated by ChatGPT 5