Yogurt factory(POJ 2393, 贪心)

题目链接

      这个题就比较简单了,算是我做的最快的几个题之一了,不过还是WA了一次,因为看到“Note that the total might be too large for a 32-bit integer.”后,我果断使用了long类型而忘了long也是32位,还好我很快就反应过来了,不然又要浪费时间去检查代码了。

/*i周的per unit of yogurt的最低成本为b[i]
最低cost即求和b[i]*Y[i]  
	递推可得b[i]的值 
	b[0] = c[0];
	b[i] = min(b[i-1]+S, c[i]);
*/
#include
#include

using namespace std;

const int MAX_N = 10005;
long long ans;
int N, S, C[MAX_N], Y[MAX_N], b[MAX_N];

void ini()
{
	for(int i=0; i


你可能感兴趣的:(挑战程序设计竞赛!)