日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

D. Timetable

發布時間:2023/12/13 综合教程 39 生活家
生活随笔 收集整理的這篇文章主要介紹了 D. Timetable 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

http://codeforces.com/problemset/problem/946/D

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

There aremworking hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first lesson is duringi-th hour, and last lesson is duringj-th hour, then he spendsj?-?i?+?1hours in the university during this day. If there are no lessons during some day, then Ivan stays at home and therefore spends0hours 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 thanklessons 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.

Givenn,m,kand 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 thanklessons?

Input

The first line contains three integersn,mandk(1?≤?n,?m?≤?500,0?≤?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.

Thennlines follow,i-th line containing a binary string ofmcharacters. Ifj-th character ini-th line is1, then Ivan has a lesson oni-th day duringj-th hour (if it is0, there is no such lesson).

Output

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

Examples

input
Copy

2 5 1
01001
10110

output

5

input
Copy

2 5 0
01001
10110

output

8

Note

In the first example Ivan can skip any of two lessons during the first day, so he spends1hour during the first day and4hours during the second day.

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

// 去吧!皮卡丘! 把AC帶回來!
//      へ     /|
//   /\7    ∠_/
//   / │   / /
//  │ Z _,< /   /`ヽ
//  │     ヽ   /  〉
//  Y     `  /  /
//  ?● ? ●  ??〈  /
//  ()  へ    | \〈
//   >? ?_  ィ  │ //
//   / へ   / ?<| \\
//   ヽ_?  (_/  │//
//    7       |/
//    >―r ̄ ̄`?―_
//**************************************
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 2147483647
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define ri register int
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) {
  return min(min(a, b), min(c, d));
}
template <class T> inline T max(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
#define pi acos(-1)
#define mem(x, y) memset(x, y, sizeof(x));
#define For(i, a, b) for (int i = a; i <= b; i++)
#define FFor(i, a, b) for (int i = a; i >= b; i--)
#define bug printf("***********
");
#define mp make_pair
#define pb push_back
const int maxn = 3e5 + 10;
// name*******************************
int n, m;
int a[505][505];
int K;
int kk[505][505];//kk[i][j]記錄第i行刪掉j個的最小代價,為后面dp服務
int dp[505][505];//dp[i][j]:前i行,共刪掉j個所獲最下代價
int cnt[505];//記錄每組的1的個數
int sum=0;  //sum這里記錄下1的總個數,若K大于sum,直接輸出0
// function******************************

//***************************************
int main() {
  // ios::sync_with_stdio(0); cin.tie(0);
  // freopen("test.txt", "r", stdin);
  //  freopen("outout.txt","w",stdout);
  cin >> n >> m >> K;
  me(dp, 127);
  me(kk, 127);
  For(i, 1, n) {
    For(j, 1, m) {
      int x;
      scanf("%1d", &x);//限寬輸入
      if (x) {
        a[i][++cnt[i]] = j;
      }
    }
    //選定j,k為起始終止點
    For(j, 1, cnt[i]) {
      For(k, j, cnt[i]) {
        kk[i][(j - 1) + cnt[i] - k] =
            min(kk[i][(j - 1) + cnt[i] - k], a[i][k] - a[i][j] + 1);
      }
    }
    kk[i][cnt[i]] = 0;
    sum+=cnt[i];
  }
if(K>=sum){
  cout<<0;
  return 0;
}
  For(i, 0, min(K, cnt[1])) {
    dp[1][i] = kk[1][i];
  }
  For(i, 2, n) {
    For(j, 0, K) {
      For(k, 0, min(j,cnt[i])) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j - k] + kk[i][k]);
      }
    }
  }
  cout << dp[n][K];

  return 0;
}

總結

以上是生活随笔為你收集整理的D. Timetable的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 黄色特级一级片 | 娇妻被老王脔到高潮失禁视频 | 国产精品国产三级国产普通话对白 | 99爱免费视频 | 99视频一区二区 | 欧美激情久久久久久 | 欧美在线一区二区视频 | 九色国产精品 | 国产综合精品久久久久成人影 | 国产精品免费无码 | 日韩一区二区三区网站 | 国产视频精品一区二区三区 | 日日舔夜夜摸 | 性色av一区二区三区免费 | 免费看亚洲 | 日韩欧美二区三区 | 成人高清在线观看 | 五月婷婷在线观看 | jizz视频在线观看 | 光溜溜视频素材大全美女 | xxxxhd欧美 | 无码精品人妻一区二区三区漫画 | 人人cao| 农村寡妇一区二区三区 | 亚洲大色网| 免费国产视频在线观看 | wwww黄色片 | 在线观看黄网址 | 国产探花视频在线观看 | 日本丰满少妇 | 国产人妻aⅴ色偷 | 四虎最新网址在线观看 | 九九热九九热 | 91亚瑟| 国产九色91回来了 | 不卡视频在线播放 | 成人黄色在线网站 | 黄色一级大片在线免费看国产一 | 小向美奈子在线观看 | 有码一区| 亚洲AV成人无码电影在线观看 | 欧美日韩一区二区三区不卡视频 | 黄色一区二区三区四区 | 亚欧成人 | 久久国产精品国产精品 | 国产人妖在线观看 | 亚洲精品自拍 | 午夜大片网 | 天天综合网久久 | 一级丰满大乳hd高清 | 精品中文字幕在线播放 | 天堂网色 | 欧美wwwxxxx | 欧美在线色| www久久久久久久 | 成人福利视频在线 | 日韩人体视频 | 肉丝袜脚交视频一区二区 | 成年人网站av| 国产四区 | 午夜成人亚洲理伦片在线观看 | 中日韩欧美在线观看 | 美丽的姑娘在线观看免费 | 精品久久久久一区二区国产 | 国产精品无码自拍 | 国产欧美在线观看视频 | 欧美精品高清 | 日本免费成人 | 国产成人在线观看免费网站 | 成人免费一区二区三区在线观看 | 成人第四色 | 亚洲一区二区美女 | 天堂中文字幕在线 | 丰满的人妻hd高清日本 | 成人做受视频试看60秒 | 黄色片一区 | 娇妻第一次尝试交换的后果 | 青青草社区 | 色一情一区二区三区四区 | 欧美韩国日本 | 中日韩黄色大片 | 麻豆精品影院 | 国产美女精品久久久 | 亚洲精品久久久久久宅男 | 懂色av成人一区二区三区 | 日韩性在线 | 爱爱视频一区二区 | 久久久久久亚洲中文字幕无码 | 丰满少妇一区二区三区视频 | 操久久久| 国产视频精品免费 | 不卡视频一区 | 人妻精品久久久久中文字幕 | 99久久99久久久精品棕色圆 | 精品一区二区久久 | 九九自拍视频 | 手机成人免费视频 | 91精品国| 人人澡人人澡 |