QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#182753#6727. K-hour Clockucup-team004WA 0ms3524kbC++20836b2023-09-18 15:03:412023-09-18 15:03:43

Judging History

你现在查看的是最新测评结果

  • [2023-09-18 15:03:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2023-09-18 15:03:41]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, k;
    std::cin >> n >> k;
    
    std::string s;
    std::cin >> s;
    
    int lo = 1, hi = n;
    while (lo < hi) {
        int L = (lo + hi) / 2;
        int r = -1;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == '1') {
                if (i > r) {
                    r = i + L - 1;
                    cnt++;
                }
            }
        }
        if (cnt <= k) {
            hi = L;
        } else {
            lo = L + 1;
        }
    }
    
    std::cout << lo << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3524kb

input:

4
11 18 5
3 49 4
1 9 1
1 3 10

output:

1
1
1
1

result:

wrong answer Case #1: k <= x (x = 11, y = 18, z = 5, k = 1)