跳到正文

个人记录

ε=ε=ε=(#>д<)ノ

_xiaoxiao_约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年8月18日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include <iostream>
using namespace std;

int main() {
    int n, k, z=0;
    string s;
    cin >> n >> k >> s;

    for (char c : s)
        if (c == '0') z++;

    if (z == 0) {
        cout << 0 << endl;
        return 0;
    }

    int c1 = z;
    int c2 = k + (n - z);
    cout << min(c1, c2) << endl;

    return 0;
}
原文