QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#661496#5417. Chat ProgramwsyjpgsWA 70ms13040kbC++141.3kb2024-10-20 16:32:512024-10-20 16:32:51

Judging History

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

  • [2024-10-20 16:32:51]
  • 评测
  • 测评结果:WA
  • 用时:70ms
  • 内存:13040kb
  • [2024-10-20 16:32:51]
  • 提交

answer

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

long long a[500005];

int main()
{
	long long n,k,m,c,d;
	cin>>n>>k>>m>>c>>d;
	
	priority_queue<long long,vector<long long>,greater<long long>> q;
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(q.size()<k)
		{
			q.push(a[i]);
		}
		else if(a[i]>q.top())
		{
			q.pop();
			q.push(a[i]);
		}
	}
	
	long long p=q.top(),pos=0,st=0,ed=0;
	
	long long sum=0,maxp=0,sump=0,posp=0;
	while(ed<m)
	{
		if(a[ed]+c>p)
		{
			sum++;
		}
		if(a[ed]==p)
		{
			sump++;
		}
		ed++;
	}
	int i=st,j=ed;
	while(j<n)
	{
		if(sum>maxp||(sum==maxp&&sump>posp))
		{
			st=i;
			ed=j;
			maxp=sum;
			posp=sump;
		}
	
		//maxp=max(maxp,sum);
		if(a[i]+c>p)
		{
			sum--;
			if(a[i]==p)
			{
				sump--;
			}
		}
		i++;
		j++;
		if(a[j]<=p)
		{
			sum++;
			if(a[i]==p)
			{
				sump++;
			}
		}
	}
	//cout<<"st:"<<st<<"ed:"<<ed<<endl;

	map<long long,long long> ma;
	//cout<<"st:"<<st<<"ed:"<<ed<<endl;
	for(int i=st;i<=ed;i++)
	{			
		if(a[i]+c>p)
		{
			if(a[i]<=p)
			{
				q.pop();
				q.push(a[i]+c);
				p=q.top();
				while(ma[p]>0)
				{
					ma[p]--;
					q.pop();
					q.push(p+c);
					p=q.top();
				}
			}
			else
			{
				ma[a[i]]++;
			}
		}
		c+=d;
	}
	cout<<q.top()<<endl;
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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: 19ms
memory: 7452kb

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: 70ms
memory: 13040kb

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:

100002000000000

result:

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