QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745271#5417. Chat ProgramHHSWA 29ms6204kbC++141.0kb2024-11-14 08:52:472024-11-14 08:52:48

Judging History

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

  • [2024-11-14 08:52:48]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:6204kb
  • [2024-11-14 08:52:47]
  • 提交

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=1e9;
	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)
				{
					cha[i]++;
					ll s=min(n+1,i+m);
					cha[s]--;
				}
			}
			else{
				ll x=(mid-a[i]-c+d-1)/d;
				if(x<=m-1)
				{
					cha[i]++;
					ll s=min(n+1,i+m-x);
					cha[s]--;
				}
			}
			
		}
		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: 100
Accepted
time: 0ms
memory: 3808kb

input:

6 4 3 1 2
1 1 4 5 1 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

7 3 2 4 0
1 9 1 9 8 1 0

output:

9

result:

ok 1 number(s): "9"

Test #3:

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

input:

8 3 5 0 0
2 0 2 2 1 2 1 8

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 29ms
memory: 6204kb

input:

200000 200000 100000 0 1000000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: -100
Wrong Answer
time: 15ms
memory: 6196kb

input:

200000 1 100000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

1000000000

result:

wrong answer 1st numbers differ - expected: '100001000000000', found: '1000000000'