QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#182753 | #6727. K-hour Clock | ucup-team004 | WA | 0ms | 3524kb | C++20 | 836b | 2023-09-18 15:03:41 | 2023-09-18 15:03:43 |
Judging History
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)