QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#563589#8783. Cherry Pickingdonghanwen1225Compile Error//C++20464b2024-09-14 14:02:222024-09-14 14:02:23

Judging History

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

  • [2024-09-14 14:02:23]
  • 评测
  • [2024-09-14 14:02:22]
  • 提交

answer

#include<iostream>
#include<cstdio>
using namespace std;
int n,k,r[100005];char s[100005];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>r[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(r[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

answer.code: In function ‘int main()’:
answer.code:16:29: error: invalid types ‘int[int]’ for array subscript
   16 |                         if(r[i]>=mid)
      |                             ^