题解
2023-07-07 12:43:30
发布于:上海
17阅读
0回复
0点赞
#include <iostream>
using namespace std;
double w, l;
int n;
double a[1100], b[1100], f[1100];
int main()
{
cin >> w >> l >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
f[i] = 99999999999999999;
}
f[1] = l / b[1] * 60;
f[0] = 0;
for (int i = 2; i <= n; i++)
{
double weight = 0;
double ms = b[i];
for (int j = i; j >= 1; j--)
{
weight += a[j];
if (weight > w)
break;
if (b[j] < ms)
ms = b[j];
f[i] = min(f[i], f[j - 1] + l / ms * 60);
}
}
printf("%.1f", f[n]);
return 0;
}
这里空空如也
有帮助,赞一个