QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#661513#5417. Chat ProgramwsyjpgsWA 95ms18424kbC++141.3kb2024-10-20 16:37:012024-10-20 16:37:04

Judging History

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

  • [2024-10-20 16:37:04]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:18424kb
  • [2024-10-20 16:37:01]
  • 提交

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-1)
	{
		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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3828kb

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

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

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: 25ms
memory: 7952kb

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: 75ms
memory: 13224kb

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: 0
Accepted
time: 95ms
memory: 18424kb

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:

200001000000000

result:

ok 1 number(s): "200001000000000"

Test #7:

score: -100
Wrong Answer
time: 57ms
memory: 7912kb

input:

200000 24420 17993 881138881 700368758
231187558 519018952 260661004 740633836 931672020 155904999 647179942 13217847 779799803 382810661 242588977 708308843 309853544 225488875 389115097 588643904 644409212 704920939 231829287 39891424 881158891 341251089 486868469 808002305 629160633 317239613 771...

output:

964183791

result:

wrong answer 1st numbers differ - expected: '964474978', found: '964183791'