QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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)