QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516942#8783. Cherry PickingSocialPandaWA 0ms3752kbC++231.2kb2024-08-13 00:45:522024-08-13 00:45:52

Judging History

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

  • [2024-08-13 00:45:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3752kb
  • [2024-08-13 00:45:52]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
//#define int long long
//#define LL long long
#define double long double
//#define lf Lf
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define PII pair<int,int>
#define Gheap priority_queue<int,vector<int>,greater<int>>
#define Lheap priority_queue<int>
#define MAXN 0x3f3f3f3f
#define MINN -0x3f3f3f3f
using namespace std;
const int N=1e6+100,M=2*N;
//int e[N],w[M],h[M],ne[M],idx;

int a[N];
string s;
int n,k;

bool check(int num)
{
	int cnt=0;
	char pre='.';
	for(int i=1;i<=n;i++)
	{
		if(a[i]<num) continue;
		//cout<<s[i]<<'!'<<endl;
		if(pre=='1' and pre==s[i]) cnt++;
		else cnt=1;
		if(cnt>=k) return true;
		pre=s[i];
	}
	return false;
}

void solve()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	cin>>s;s=' '+s;
	
	int ll=0,rr=n;

	//cout<<check(0)<<endl;

	while(ll<rr)
	{
		int mid=ll+rr+1>>1;
		if(check(mid)) ll=mid;
		else rr=mid-1;
	}
	cout<<ll<<endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

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

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

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

input:

1 1
1
1

output:

1

result:

ok answer is '1'

Test #4:

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

input:

1 1
1
0

output:

1

result:

wrong answer expected '0', found '1'