为什么我RE了?数组已经很大了啊?
查看原帖
为什么我RE了?数组已经很大了啊?
177838
IGD_XW楼主2020/9/19 13:13
#include<bits/stdc++.h>
using namespace std;
long long n,m;//蚯蚓个数和总共时间 
long long q;//切断后其他蚯蚓长的长度 
long long u,v;//u/v就是p的值,表示切的长度([px]&x-[px])——x*u/v 
long long t;//输出的方式 
long long a[1000010];
queue<int> q1,q2,q3;
long long sum;
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<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	n=read(),m=read();
	q=read(),u=read(),v=read(),t=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		q1.push(a[i]);
	}
	sum=0;
	for(int i=1;i<=m;i++)
	{
		int k=-999;
		int o=0;
		if(!q1.empty()&&k<=q1.front())
		{
			k=q1.front();
			o=1;
		}
		if(!q2.empty()&&k<=q2.front())
		{
			k=q2.front();
			o=2;
		}
		if(!q3.empty()&&k<=q3.front())
		{
			k=q3.front();
			o=3;
		}
		if(o==1) q1.pop();
		if(o==2) q2.pop();
		if(o==3) q3.pop();
		k+=sum;
		if(i%t==0) cout<<k<<" ";
		int x,y;
		x=k*u/v;
		y=k-x;
		sum+=q;
		x-=sum;
		y-=sum;
		q2.push(x);
		q3.push(y);
	}
	cout<<"\n";
	int l=1;
	while(!q1.empty()||!q2.empty()||!q3.empty())
	{
		int _1=-999999,_2=-999999,_3=-999999;
		if(!q1.empty())
		{
			_1=q1.front();
		}
		if(!q2.empty())
		{
			_2=q2.front();
		}
		if(!q3.empty())
		{
			_3=q3.front();
		}
		if(_1>=_2&&_1>=_3)
		{
			if(l%t==0) cout<<_1+sum<<" ";
			q1.pop();
		}
		else if(_2>=_1&&_2>=_3)
		{
			if(l%t==0) cout<<_2+sum<<" ";
			q2.pop();
		}
		else if(_3>=_1&&_3>=_2)
		{
			if(l%t==0) cout<<_3+sum<<" ";
			q3.pop();
		}
		l++;
	}
	return 0;
}
2020/9/19 13:13
加载中...