QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786345#5417. Chat Program123adadWA 50ms6204kbC++23852b2024-11-26 21:10:252024-11-26 21:10:30

Judging History

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

  • [2024-11-26 21:10:30]
  • 评测
  • 测评结果:WA
  • 用时:50ms
  • 内存:6204kb
  • [2024-11-26 21:10:25]
  • 提交

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(1ll,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;
}

詳細信息

Test #1:

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

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

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

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

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

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: 50ms
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'