QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786350#5417. Chat Program123adadWA 47ms6356kbC++23852b2024-11-26 21:11:062024-11-26 21:11:06

Judging History

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

  • [2024-11-26 21:11:06]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:6356kb
  • [2024-11-26 21:11:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	
	ll n,k,m,c,d;
	cin>>n>>k>>m>>c>>d;
	vector<ll> a(n+1);

	for(int i=1;i<=n;i++){
		cin>>a[i];
	}

	auto check=[&](ll x)->bool{
		ll res=0,cnt=0;
		vector<ll> dx(n+1,0);
		for(int i=1;i<=n;i++){
			if(a[i]>=x){
				cnt++;
				continue;
			}
			if(a[i]+c+(m-1)*d<x){
				continue;
			}
			ll temp=0;
			if(a[i]+c>=x){
				temp=0;
			}else{
				temp=(x-a[i]-c)/d+((x-a[i]-c)%d?1:0);
			}
			
			if(i-temp<0){
				continue;
			}
			dx[max(0ll,i-m)]++;
			dx[i-temp]--;
		}
		for(int i=1;i<=n;i++){
			dx[i]+=dx[i-1];
			res=max(res,cnt+dx[i]);
		}
		return res>=k;
	};

	ll l=-1,r=1e18;
	while(l+1!=r){
		ll mid=(l+r)>>1;
		if(check(mid)) l=mid;
		else r=mid;
	}
	cout<<l;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3480kb

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: 3608kb

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: 42ms
memory: 6200kb

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: 0
Accepted
time: 38ms
memory: 6356kb

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:

100001000000000

result:

ok 1 number(s): "100001000000000"

Test #6:

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

input:

200000 1 200000 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:

200000000000000

result:

wrong answer 1st numbers differ - expected: '200001000000000', found: '200000000000000'