QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#500967#8783. Cherry Pickingydzr00000WA 0ms4060kbC++20799b2024-08-02 08:28:342024-08-02 08:28:38

Judging History

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

  • [2024-08-02 08:28:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4060kb
  • [2024-08-02 08:28:34]
  • 提交

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;
        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: 3860kb

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

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

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

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

input:

1 1
1
1

output:

2

result:

wrong answer expected '1', found '2'