https://www.luogu.org/problem/show?pid=1376
简单的贪心,居然之前还想不到。。感觉快完了
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ms(i,j) memset(i,j, sizeof i);
/* NOIP2016倒计时,RP++
Luogu: P1376 机器工厂
*/
using namespace std;
int n,s;
int last;
long long ans = 0;
int main()
{
scanf("%d%d", &n, &s);
for (int i=1;i<=n;i++)
{
int c,y;
scanf("%d%d", &c, &y);
if (i==1) last = c;
last = min(last+s,c);
ans += (long long)last*(long long)y;
}
printf("%lld\n", ans);
return 0;
}