$贪心题$
$思路比较直接,第i天的需求为d_i$
$设两个变量lefta表示当前有柠檬片的库存数量,leftb表示当前有养乐多的库存量$
$如果当前库存量够当天使用,则直接使用库存的,如果不够,则在前i天中找最便宜的一天提前购买存货即可。$
#include <bits/stdc++.h>
using namespace std;
const int N = 1010,INF=0x3f3f3f3f;
int c[N], a[N], b[N];
int n, A, B;
int lefa , lefb;
long long cost ;
int main() {
scanf("%d%d%d", &n, &A, &B);
int mina = INF, minb = INF;
for (int i = 1; i <= n; i++) {
scanf("%d%d%d", &c[i], &a[i], &b[i]);
mina = min(mina, a[i]); //统计前面最便宜的一天
minb = min(minb, b[i]);
cost += A * c[i] * mina; //缺少的养乐多可以直接买
if (lefb >= B * c[i]) { //柠檬可能有余量
lefb -= B * c[i];
} else {
int need = B * c[i] - lefb;
need = ceil(need / 80.0);
cost += need * minb; //从前边最便宜的一天买
lefb += 80 * need - B * c[i];
}
}
printf("%lld\n", cost);
return 0;
}