TLE#6#13 90pts 求调
查看原帖
TLE#6#13 90pts 求调
752953
sLMxf楼主2023/9/26 20:07
#include<bits/stdc++.h>
#define int long long
#define inf 2100000000 //inf=2*10^9+10^8
#define max(x,y) (x>y?x:y)
using namespace std;
priority_queue<int> q1,q2,q3;
int a[100010];
int topop()
{
	int m1,m2,m3;
	if(q1.empty()) m1=-inf;
	else m1=q1.top();
	if(q2.empty()) m2=-inf;
	else m2=q2.top();
	if(q3.empty()) m3=-inf;
	else m3=q3.top();
	int maxx=max(m1,max(m2,m3));
	if(maxx==m1) q1.pop();
	else if(maxx==m2) q2.pop();
	else q3.pop();
	return maxx;
}
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
void write(int x)
{
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}
signed main()
{
	int n,m,Q,u,v,t,pi=0;
	cin>>n>>m>>Q>>u>>v>>t;
	double p=u*1.0/v;
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) q1.push(a[i]);
	for(int i=1;i<=m;i++)
	{
		int x=topop()+pi;
		if(i%t==0) write(x),cout<<" ";
		pi+=Q;
		int x1=x*1.0*p;int x2=x-x1;
		q2.push(x1-pi);
		q3.push(x2-pi);
	}
	cout<<'\n';
	for(int i=1;i<=n+m;i++)
	{
		int x=topop()+pi; 
		if(i%t==0) write(x),cout<<" ";
	}
	return 0;
}
2023/9/26 20:07
加载中...