QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#752195#5417. Chat ProgramHHSWA 0ms3496kbC++141.2kb2024-11-15 22:49:422024-11-15 22:49:43

Judging History

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

  • [2024-11-15 22:49:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3496kb
  • [2024-11-15 22:49:42]
  • 提交

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)
		{
			l=mid+1;
			continue;
		}
		for(ll i=1;i<=n;i++)
		{
			if(a[i]>=mid)continue;
			if(d==0)
			{
				if(a[i]+c>=mid)
				{
					ll zuo,you;
					zuo=max((ll)1,i-m+1);
					you=min(i,n-m+1);
					cha[zuo]++;
					cha[you+1]--;
				}
			}
			else{
				ll x=(mid-a[i]-c+d-1)/d;
				x=max(x,(ll)0);
				if(x<=m-1)
				{
					ll zuo,you;
					zuo=max((ll)1,i-m+1);
					you=max((ll)1,i-x+1);
					cha[zuo]++;
					cha[you+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();
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3496kb

input:

6 4 3 1 2
1 1 4 5 1 4

output:

5

result:

wrong answer 1st numbers differ - expected: '4', found: '5'