$ c_x * y_{i_2} + (i_2-x) * y_{i_2} * s < c_{i_1} * y_{i_2} + (i_2-i_1) * y_{i_2} * s $

/*
思路:贪心 (又一次抄题解...)
考虑到每周的奶酪可由前几周的储存 也可本周制作
可证明出若第x周生产i1周所需奶酪更便宜 则i2周的奶酪在第x周生产一定比在第i1周生产更便宜 
因此可以把每周储存成本看成价格的一部分 则当前选取方案只有从以前最便宜的一周生产和这一周生产两种选择
贪心选取
*/
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long LL;
int n,s;
LL ans,now=0x3f3f3f3f3f3f3f3f;
int main(){
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;++i){
		LL c,y;scanf("%lld%lld",&c,&y);
		now=min(now+s,c);
		ans+=y*now;
	}
	printf("%lld",ans);
	return 0;
}

相关文章:

  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-09-29
  • 2021-11-15
  • 2021-12-14
  • 2021-12-14
相关资源
相似解决方案