QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150211 | #6726. Turn It Off | supepapupu | AC ✓ | 6ms | 3856kb | C++17 | 850b | 2023-08-25 15:46:57 | 2023-08-25 15:46:59 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 2e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
char str[N];
void solve() {
int n, k;
cin >> n >> k;
cin >> str + 1;
int l = 1, r = 2e5, mid;
auto check = [&](int mid) {
int cnt = 0;
for (int i = 1; i <= n; ++i) {
if (str[i] == '0') continue;
i += mid - 1, ++cnt;
}
return cnt <= k;
};
while (l < r) {
mid = l + r >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
}
cout << l << el;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int tcase = 1;
cin >> tcase;
while (tcase--) solve();
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
input:
2 10 4 0101011111 3 1 010
output:
3 1
result:
ok 2 number(s): "3 1"
Test #2:
score: 0
Accepted
time: 6ms
memory: 3856kb
input:
1109 47 36 11101110101001111110101101100001000011101001011 6 5 100010 35 26 00011111000000101010011010100101111 71 45 11101001000111011101101000000000010001100100110000001000011011001011000 32 23 00000100011110010101000110010110 36 30 110110000000000011010001100011111100 21 8 010000011010011101100 9...
output:
1 1 1 1 1 1 2 4 10 2 2 3 3 1 2 1 1 1 1 2 2 2 6 7 1 1 1 1 1 1 1 3 1 1 2 3 1 1 3 1 1 6 1 1 5 1 1 3 10 19 1 1 1 4 1 1 2 1 2 1 1 2 1 1 60 17 3 3 2 2 1 1 4 1 1 1 1 1 2 2 1 3 5 2 1 1 4 2 1 1 3 1 1 1 1 1 5 2 3 1 2 1 1 1 1 2 1 1 2 1 1 81 1 4 1 1 1 2 1 44 1 5 2 3 1 1 1 2 1 8 1 1 3 1 1 2 1 46 1 1 1 1 1 1 1 1 ...
result:
ok 1109 numbers