QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#499546 | #6726. Turn It Off | pagohia | TL | 0ms | 3560kb | C++14 | 600b | 2024-07-31 15:35:27 | 2024-07-31 15:35:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
string s;
int L, k, len;
bool f(int LL)
{
int cnt = 0;
for(int i = 0; i < len; i++)
if(s[i] == '1')
{
i += (LL - 1);
cnt++;
if(cnt > k)
return 1;
}
return 0;
}
void F(int l, int r)
{
int m = (l + r) / 2;
if(f(l) && !f(l + 1))
L = l + 1;
else if(f(m))
F(m, r);
else
F(l, m - 1);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--)
{
cin >> len >> k;
cin >> s;
L = len / k + 1;
if(len % k == 0)
L--;
F(1, L);
cout << L << endl;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2 10 4 0101011111 3 1 010
output:
3 1
result:
ok 2 number(s): "3 1"
Test #2:
score: -100
Time Limit Exceeded
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