P8508 - WA Subtask5 第一个点
查看原帖
P8508 - WA Subtask5 第一个点
325995
Zxd2009楼主2022/9/11 11:44
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int n, x, p, q;
long long day, td, t[100005], tt[100005];
double w;

int main()
{
	scanf("%d%d%d%d", &n, &x, &p, &q);
	w = x - (1.0 * p / q) * x;
	for(int i = 1; i <= n; i++)
	{
		scanf("%lld", &t[i]);
		tt[i] = tt[i - 1] + t[i];
	}
	for(int i = 1; i <= n; i++)
	{
		if(td + t[i] >= x)
		{
			day++;
			td = 0;
		}
		if(day * w < tt[i])
		{
			day = ceil(tt[i] / w);
			td = 0;
		}
		td += t[i];
	}
	printf("%lld", day);
	return 0;
}

提交记录

2022/9/11 11:44
加载中...