题意
传送门 POJ 2393
每周的货物费用取可能的最小花费即可,即 m i n c o s t = m i n ( m i n c o s t + S , C [ i ] ) mincost=min(mincost+S,C[i]) mincost=min(mincost+S,C[i])。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define abs(x) ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_N 10005
using namespace std;
typedef long long LL;
int N, S;
int C[MAX_N], Y[MAX_N];
int main(){
while(~scanf("%d%d", &N, &S)){
for(int i = 0; i < N; i++) scanf("%d%d", C + i, Y + i);
LL res = 0;
int mincost = INF;
for(int i = 0; i < N; i++){
mincost = min(mincost + S, C[i]);
res += mincost * Y[i];
}
printf("%lld\n", res);
}
return 0;
}