Description
N周,每周有一个酸奶价钱和要卖出的酸奶数,也可以存之前的酸奶来买,不过要付每周S的储存费,酸奶不会坏= =。问罪节省成功的弄法?
Algorithm
记录个最少价钱,每次和上一次比,然后看刷不刷新
注意
Note that the total might be too large for a 32-bit integer
要用long long
Code
#include <cstdio>
#include <iostream>
using namespace std;
const int INF = 2e9;
int main()
{
int n, s;
scanf("%d%d", &n, &s);
int mins = INF;
long long ans = 0;
for (int i = 0; i < n; i++)
{
int c, y;
scanf("%d%d", &c, &y);
if (c < mins + s) mins = c; else mins += s;
ans += mins * y;
}
cout<<ans;
return 0;
}
本文探讨了在一周内制定酸奶生产计划的方法,旨在通过合理的定价和库存策略,实现成本最小化的目标。通过引入存储费用的概念,文章详细阐述了如何在不同价格和需求场景下做出最优决策。


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



