cswork / OAOpen practice workspace

MicrosoftOA #28

Get Minimum Time

Estimated HardJudge-ready

Topics (AI-labelled)KnapsackPrefix & Ranges

The time spent at school on a day is the difference in hours between the latest and earliest classes attended that day, plus 1; it is 0 if no class is attended. You may skip at most K classes in total. Find the minimum total time at school over all days.

Input

The first line contains N M K (each 1..200), followed by N lines, each a 01 string of length M.

Output

Output a single integer, the answer.

Example 1

Input:

1 5 1
10001

Output:

1

Example 2

Input:

2 2 1
11
01

Output:

2

Example 3

Input:

1 3 1
000

Output:

0

Example notes

Example 1: skip either class and attend only the other, spending 1 hour at school.

Example 2: skip the only class on the second day; the first day takes 2 hours, for a total of 2.

Example 3: there are no classes, so there is no need to go to school; the answer is 0.

Editorial

Loading solution…