#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
double p[8], d[8];
double d1, c, d2, x;
int n;
double min = 0;
cin >> d1 >> c >> d2 >> p[0] >> n;
d[0] = 0;
d[n + 1] = d1;
for (int i = 1; i <= n; i++)
cin >> d[i] >> p[i];
for (int i = 0; i <= n; i++)
{
if (i != 0) x -= (d[i] - d[i - 1]) / d2;
else x = 0;
if (c * d2 < d[i + 1] - d[i])
{
cout << "No Solution" << endl;
return 0;
}
int t = 0;
for (int j = i + 1; j <= n; j++)
{
if (c * d2 < d[j] - d[i]) break;
if (p[j] < p[i])
{
t = j;
break;
}
}
if (t == 0)
{
if (d[n + 1] - d[i] < c * d2)
{
min += ((d[n + 1] - d[i]) / d2 - x) * p[i];
printf("%.2lf", min);
return 0;
}
else
{
min += (c - x) * p[i];
x = c;
}
}
else
{
double need = (d[t] - d[i]) / d2;
if (x < need)
{
min += (need - x) * p[i];
x = need;
}
}
}
}
洛谷P1016 旅行家的预算
最新推荐文章于 2024-09-09 13:30:04 发布

253

被折叠的 条评论
为什么被折叠?



