求助:为什么RE#28#29
查看原帖
求助:为什么RE#28#29
796838
Zak_chen楼主2023/4/30 00:05
求助为什么玄学RE
感谢大佬帮忙
#include<bits/stdc++.h>
#define N 5000005
#define LD long double
using namespace std;
int n;
LD p,q,x;//n个任务 每天x小时  
LD t[N],s[N],stot;
queue<LD>Q;
int main()
{
/*	freopen("homework.in","r",stdin);
	freopen("homework.out","w",stdout);*/
	scanf("%d%Lf%Lf%Lf",&n,&x,&p,&q);
	for(int i=1;i<=n;i++)
	{
		scanf("%Lf",&t[i]);
		Q.push(t[i]);
	}
	LD r=p*1.00/q; int day=0;
//	cout<<r<<endl;
	while(1)
	{
		day++;
		LD t = r*x*day;//前day天保证的睡眠时间 
		
		s[day]=t-stot;//至少睡眠时间  
		if(s[day]<=0) s[day]=0.00001;
		LD use = x-s[day];//最多可用的 
	//	printf("t=%lf s[day]=%lf use=%lf\n",t,s[day],use);
		LD tot=0;//已经用的 
		while(!Q.empty()&&Q.front()+tot<=use)
		{
			tot+=Q.front();
			Q.pop(); 
		}
		if(Q.empty())
		{
			printf("%d",day);
			return 0;
		}
	//	printf("stot=%lf tot=%lf\n",stot,tot);
		stot+=x-tot;
	}
	return 0;
}
2023/4/30 00:05
加载中...