QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499407#6726. Turn It OffbuzhijingdiWA 11ms3880kbC++14751b2024-07-31 13:55:342024-07-31 13:55:35

Judging History

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

  • [2024-07-31 13:55:35]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3880kb
  • [2024-07-31 13:55:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 9;
const int mod = 1e9 + 7;
#define eps 1e-5
#define inf 2e18
int n,k;
char s[N];

bool check(int x)
{
    int cnt=0,i;
    for(i=1;i<=n;++i)
    {
        if(s[i]=='1')
        {
            i = i + x - 1;
            cnt++;
        }
    } 
    return  cnt>=x;
}

void solve()
{
   cin>>n>>k;
   cin>>s+1;

    int l = 1, r = 2e5 + 100;
     while(l < r)
    {
        int mid = (l + r + 1) >> 1;
        if(check(mid)) l = mid;
        else r = mid-1;
    }
    cout<< l << '\n';
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;  cin>>_;
    while (_--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

2
10 4
0101011111
3 1
010

output:

3
1

result:

ok 2 number(s): "3 1"

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 3880kb

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:

7
2
5
7
5
5
4
9
9
5
8
3
8
9
1
7
10
5
5
3
1
7
6
9
7
7
9
1
6
9
8
6
5
9
5
9
9
3
4
9
7
7
9
7
5
6
1
5
7
8
8
9
8
8
6
6
4
4
9
8
8
7
3
8
7
7
7
7
5
7
8
9
5
7
4
10
1
10
5
9
7
9
4
7
5
7
10
9
9
6
6
4
4
6
7
6
6
9
9
6
7
1
9
7
8
8
7
8
8
2
1
9
9
9
6
6
5
2
8
5
6
8
3
3
6
4
8
9
9
8
2
8
6
6
6
8
9
9
8
7
8
7
2
6
5
9
8
7
...

result:

wrong answer 1st numbers differ - expected: '1', found: '7'