#P6001. [CEOI 2016] popeala

[CEOI 2016] popeala

Description

You hosted a contest with nn participants. There is only one problem, and it has mm test points, numbered from 11 to mm. Each test point has a score aia_i.

Now all contestants have submitted their programs and all submissions have been judged. You know which test points each person can pass.

You now need to arrange a bundled testing method by partitioning the test points into several consecutive intervals, where each interval contains at least one test point. For each interval, if there is at least one wrong test point, then no score is obtained for that interval; if all test points in the interval are correct, then the score of the interval is the sum of the scores of all test points in it.

Your goal is to minimize the sum of all participants' scores. For 1iS1\le i\le S, output the minimum possible total score of all participants when all test points are partitioned into ii groups.

Input Format

The first line contains three integers n,m,Sn,m,S.

The next line contains mm integers, representing aia_i.

The next nn lines each contain a binary string of length mm consisting of 00 and 11, where it indicates whether person ii passes test point jj.

Output Format

Output SS lines. Each line contains one integer, representing the minimum possible total score of all participants when the test points are partitioned into ii bundled groups.

2 3 3
4 3 5
101
110
0
8
16

Hint

For 100%100\% of the testdata, 1n501\le n\le 50, 1m2×1041\le m\le 2\times 10^4, Smin(50,m)S\le \min(50,m), 1ai1041\le a_i \le 10^4, Σai×n2×109\Sigma a_i\times n\le 2\times10^9.

Translated by ChatGPT 5