BZOJ 1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 贪心_问题转化

BZOJ 1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 贪心_问题转化

好久以前碰到的题,真的好巧妙

Code:

#include
#define setIO(s) freopen(s".in","r",stdin) 
#define ll long long   
using namespace std;
int main()
{
	// setIO("input"); 
	int n; 
	ll s,c,y,cur=0,ans=0;   
	scanf("%d%lld",&n,&s); 
	scanf("%lld%lld",&c,&y); 
	ans+=c*y, cur=c; 
	for(int i=2;i<=n;++i)
	{
		scanf("%lld%lld",&c,&y); 
		cur=min(cur+s,c); 
		ans+=cur*y; 
	}
	printf("%lld\n",ans); 
	return 0; 
}

  

posted @ 2019-06-04 11:30 EM-LGH 阅读( ...) 评论( ...) 编辑 收藏

你可能感兴趣的:(BZOJ 1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 贪心_问题转化)