QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499424#6726. Turn It OffAbclWA 221ms5140kbC++14849b2024-07-31 14:05:112024-07-31 14:05:11

Judging History

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

  • [2024-07-31 14:05:11]
  • 评测
  • 测评结果:WA
  • 用时:221ms
  • 内存:5140kb
  • [2024-07-31 14:05:11]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,m;
string s;
int l,r;
void solve(){
	cin>>n>>m;
	cin>>s;s=' '+s;
	int k=0;
	vector<int> nums;
	for(int i=1;i<=n;i++){
		if(s[i]=='1'){
			k++;
			nums.emplace_back(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(s[i]=='1'){
			l=i;break;
		}
	}
	for(int i=n;i>=1;i--){
		if(s[i]=='1'){
			r=i;break;
		}
	}
	for(int i=k/m;i<=r-l+1;i++){
		int x=-1;
		int t=0;
		for(int j=0;j<nums.size();j++){
			if(x<=nums[j]){
				x=nums[j]+i;
				t++;
			}
		}
		if(t<=m){
			cout<<i<<endl;
			return;
		}
	}	
	return;
}
signed main() {
	//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 221ms
memory: 5140kb

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:

0
0
0
0
0
0
2
4
10
2
2
3
3
0
2
0
0
0
0
2
2
2
6
7
0
0
0
1
0
0
0
3
0
0
2
3
0
0
3
0
0
6
0
0
5
0
0
3
10
19
0
0
0
4
0
0
2
1
2
0
0
2
0
0
60
17
3
3
2
2
0
0
4
0
0
0
1
0
2
2
0
3
5
2
0
0
4
2
0
0
3
0
1
0
0
0
5
2
3
0
2
0
0
0
0
2
0
0
2
0
1
81
0
4
0
0
0
2
0
44
0
5
2
3
0
0
0
2
0
8
1
0
3
0
0
2
0
46
0
0
0
0
0
0
0
0
...

result:

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