QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500969#8783. Cherry Pickingydzr00000WA 0ms4064kbC++20827b2024-08-02 08:30:042024-08-02 08:30:04

Judging History

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

  • [2024-08-02 08:30:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4064kb
  • [2024-08-02 08:30:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int rat[200001];
bool sta[200001];
int c[200001];
int main(){
	int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&rat[i]);
    string win;
    cin>>win;
    win=' '+win;
    int l=1,r=1e5,ans=0;
    auto check=[&](int val)->bool
    {
        int tot=0;
        fill(c+1,c+n+1,0);
        for(int i=1;i<=n;i++)
            if(rat[i]>=val)
                sta[++tot]=(win[i]-'0');
        for(int i=1;i<=tot;i++)
            c[i]=(sta[i]?c[i-1]+1:0);
        return *max_element(c+1,c+tot+1)>=k;
    };
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid))
        {
            ans=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    printf("%d\n",ans);
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

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

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

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

input:

1 1
1
1

output:

1

result:

ok answer is '1'

Test #4:

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

input:

1 1
1
0

output:

0

result:

ok answer is '0'

Test #5:

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

input:

5 3
8 3 5 2 7
10101

output:

0

result:

wrong answer expected '5', found '0'