QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745539#5417. Chat ProgramHHSCompile Error//C++141.1kb2024-11-14 10:29:072024-11-14 10:29:13

Judging History

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

  • [2024-11-14 10:29:13]
  • 评测
  • [2024-11-14 10:29:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,c,d;
void solve()
{
	cin>>n>>k>>m>>c>>d;
	vector<ll>a(n+10);
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	ll l=0,r=2e18;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		//cout<<mid<<endl;
		ll cnt=0;
		for(ll i=1;i<=n;i++)
			if(a[i]>=mid)cnt++;
		vector<ll>cha(n+10);
		if(cnt>=k)
		{
			flag=1;
		}
		for(ll i=1;i<=n;i++)
		{
			if(a[i]>=mid)continue;
			if(d==0)
			{
				if(a[i]+c>=mid)
				{
					cha[i]++;
					ll s=min(n,(ll)(i+m-1));
					cha[s+1]--;
				}
			}
			else{
				ll x=(mid-a[i]-c+d-1)/d;
				x=max(x,(ll)0);
				if(x<=m-1)
				{
					cha[i]++;
					ll s=min(n,(ll)(i+m-x-1));
					cha[s+1]--;
				}
			}
			
		}
		for(ll i=1;i<=n;i++)
			cha[i]+=cha[i-1];
		ll flag=0;
		for(ll i=1;i<=n;i++)
		{
			if(cha[i]+cnt>=k)
			{
				flag=1;
				break;
			}
		}
		if(flag)
		{
			l=mid+1;
		}
		else {
			r=mid-1;
		}
	}
	cout<<r<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	while(t--)
	{
		solve();
	}
}

Details

answer.code: In function ‘void solve()’:
answer.code:22:25: error: ‘flag’ was not declared in this scope
   22 |                         flag=1;
      |                         ^~~~