QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#563590 | #8783. Cherry Picking | donghanwen1225 | WA | 0ms | 3696kb | C++20 | 467b | 2024-09-14 14:02:47 | 2024-09-14 14:02:47 |
Judging History
answer
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,ra[100005];char s[100005];
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>ra[i];
cin>>s;
int l=1,r=100000,ans=0;
while(l<=r)
{
int mid=(l+r)/2;
int cl=0,ok=0;
for(int i=1;i<=n;i++)
if(ra[i]>=mid)
{
if(s[i-1]=='0') cl=0;
else
{
cl++;
if(cl==k) ok=1;
}
}
if(ok) ans=mid,l=mid+1;
else r=mid-1;
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3696kb
input:
5 2 1 2 3 4 5 01101
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
5 2 3 4 5 2 1 10101
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1 1 1 1
output:
1
result:
ok answer is '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1 1 1 0
output:
0
result:
ok answer is '0'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3644kb
input:
5 3 8 3 5 2 7 10101
output:
0
result:
wrong answer expected '5', found '0'