水题,compare current storing value and the price of that day, if cheaper then assign, if not then update the store value.
//#define LOCAL
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(void){
#ifdef LOCAL
freopen("data.in", "r", stdin);
#endif
int n, c, s, y;
long long store = -1;
long long ans = 0;
scanf("%d%d", &n, &s);
for(int i = 0; i < n; i++){
scanf("%d%d", &c, &y);
if(store == -1 || store > c)
store = c;
ans += store * y;
store += s;
}
printf("%lld\n", ans);
return 0;
}