QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623086#8783. Cherry Pickingrns_ksr#WA 0ms3708kbC++14703b2024-10-09 10:04:492024-10-09 10:04:50

Judging History

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

  • [2024-10-09 10:04:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-09 10:04:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define N 100050

int n, k, r[N];
int st, en, mid;

bool vis[N];
string str;

bool get(){
	for(int i = 1; i <= n; i ++)
		if(r[i] >= mid) vis[i] = 1;
		else vis[i] = 0;
	int x = 0;
	for(int i = 1; i <= n; i ++){
		if(vis[i] == 0 || str[i - 1] == '0'){
			x = 0;
			continue;
		}
		x ++;
		if(x == k) return 1;
	}
	return 0;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	
	cin >> n >> k;
    for(int i = 1; i <= n; i ++)
    	cin >> r[i];
	cin >> str;
	en = N;
	while(en - st > 1){
		mid = (st + en) / 2;
		if(get()) st = mid;
		else en = mid;
	}
	cout << st << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

1 1
1
1

output:

1

result:

ok answer is '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

1 1
1
0

output:

0

result:

ok answer is '0'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3708kb

input:

5 3
8 3 5 2 7
10101

output:

0

result:

wrong answer expected '5', found '0'