CF946D.Timetable

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Ivan is a student at Berland State University (BSU). There are nn days in Berland week, and each of these days Ivan might have some classes at the university.

There are mm working hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first lesson is during ii -th hour, and last lesson is during jj -th hour, then he spends ji+1j-i+1 hours in the university during this day. If there are no lessons during some day, then Ivan stays at home and therefore spends 00 hours in the university.

Ivan doesn't like to spend a lot of time in the university, so he has decided to skip some lessons. He cannot skip more than kk lessons during the week. After deciding which lessons he should skip and which he should attend, every day Ivan will enter the university right before the start of the first lesson he does not skip, and leave it after the end of the last lesson he decides to attend. If Ivan skips all lessons during some day, he doesn't go to the university that day at all.

Given nn , mm , kk and Ivan's timetable, can you determine the minimum number of hours he has to spend in the university during one week, if he cannot skip more than kk lessons?

输入格式

The first line contains three integers nn , mm and kk ( 1<=n,m<=5001<=n,m<=500 , 0<=k<=5000<=k<=500 ) — the number of days in the Berland week, the number of working hours during each day, and the number of lessons Ivan can skip, respectively.

Then nn lines follow, ii -th line containing a binary string of mm characters. If jj -th character in ii -th line is 1, then Ivan has a lesson on ii -th day during jj -th hour (if it is 0, there is no such lesson).

输出格式

Print the minimum number of hours Ivan has to spend in the university during the week if he skips not more than kk lessons.

输入输出样例

  • 输入#1

    2 5 1
    01001
    10110
    

    输出#1

    5
    
  • 输入#2

    2 5 0
    01001
    10110
    

    输出#2

    8
    

说明/提示

In the first example Ivan can skip any of two lessons during the first day, so he spends 11 hour during the first day and 44 hours during the second day.

In the second example Ivan can't skip any lessons, so he spends 44 hours every day.

首页