题意:
工厂要在n周生产y[i] unit的奶酪每一周生产的价格会波动,当然也可以趁着便宜的时
候多生产然后存储起来,储存需要费用,现在给出数据,问最便宜要多少钱生产这些
奶酪。
思路:
储存起来最便宜的价格然后生产既可,简单贪心。
#include<cstdio>
int main()
{
//freopen("in.txt","r",stdin);
int n,s,x,y;
__int64 sum;
while(scanf("%d%d",&n,&s) != EOF){
sum = 0;
int temp = 10000;
while(n--){
scanf("%d%d",&x,&y);
if(x > temp + s){
x = temp +s;
}
temp = x;
sum += temp*y;
}
printf("%I64d\n",sum);
}
return 0;
}