POJ 2373 Yogurt factory

时间:2023-03-09 01:55:31
POJ 2373 Yogurt factory

简单DP。

这周所用的实际花费是上一周的花费+S这周费用较小值

#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std; const int maxn=+;
long long c[maxn];
long long y[maxn];
long long S;
int n; int main()
{
while(~scanf("%d%lld",&n,&S))
{
for(int i=; i<=n; i++) scanf("%lld%lld",&c[i],&y[i]);
long long u=c[];
long long ans=c[]*y[]; for(int i=; i<=n; i++)
{
u=min(u+S,c[i]);
ans=ans+y[i]*u;
} printf("%lld\n",ans);
}
return ;
}