#P6001. [CEOI 2016] popeala
[CEOI 2016] popeala
Description
You hosted a contest with participants. There is only one problem, and it has test points, numbered from to . Each test point has a score .
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 , output the minimum possible total score of all participants when all test points are partitioned into groups.
Input Format
The first line contains three integers .
The next line contains integers, representing .
The next lines each contain a binary string of length consisting of and , where it indicates whether person passes test point .
Output Format
Output lines. Each line contains one integer, representing the minimum possible total score of all participants when the test points are partitioned into bundled groups.
2 3 3
4 3 5
101
110
0
8
16
Hint
For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号