简单的贪心 开始的时候考虑麻烦了
#include "stdio.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
struct
{
long long cost;
long long weight;
}p[10010];
int main()
{
int n,s;
while (scanf ("%d%d",&n,&s)!=EOF)
{
for (int i=1;i<=n;i++)
scanf("%I64d%I64d",&p[i].cost,&p[i].weight);
long long ans=0;
for (int i=2;i<=n;i++)
p[i].cost=min( p[i-1].cost+s, p[i].cost );
for (int i=1;i<=n;i++)
ans+=p[i].cost * p[i].weight;
printf("%I64d\n",ans);
}
return 0;
}