poj2393贪心
程序员文章站
2024-01-04 19:15:21
...
读题难受死我
提议思路: 题意:有一个奶酪场做奶酪,每天的成本在变,需要的奶酪量也在变,可以选择将奶酪存入仓库,但是仓库一天一个奶酪收S元,求最小成本
代码:
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<stdlib.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define MAX 10005
#define MAXX 10000000000000
int c[MAX], y[MAX];
int main(){
LL N,S;
LL c, y;
while(cin >> N >> S){
cin >> c >> y;
LL minp = c, sum = minp * y;
for(int i = 1 ; i < N; i++){
cin >> c >> y;
minp = min(minp + S, c);
sum += minp * y;
}
cout << sum << endl;
}
return 0;
}