QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623086 | #8783. Cherry Picking | rns_ksr# | WA | 0ms | 3708kb | C++14 | 703b | 2024-10-09 10:04:49 | 2024-10-09 10:04:50 |
Judging History
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'