#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long ll; typedef pair P; using lll=__int128_t; template struct LiChaoTree{ struct Line{ T a, b; Line(T a, T b):a(a), b(b){} inline T get(T x) const{ return a*x+b; } }; struct Node{ Node *l, *r; Line x; Node(Line x):x(x), l(nullptr), r(nullptr){} }; Node *root; LiChaoTree():root(nullptr){} Node *add(Node *t, Line &x, T l, T r){ if(!t) return new Node(x); bool bl=(x.get(l)x.get(l))^!ismin, br=(x.get(r-1)x.get(r-1))^!ismin; if(bl && br){ swap(x, t->x); return t; }else if(!bl && !br) return t; T m=(l+r)/2; bool bm=(x.get(m)x.get(m))^!ismin; if(bm) swap(x, t->x); if(bl!=bm) t->l=add(t->l, x, l, m); else t->r=add(t->r, x, m, r); return t; } void add(T a, T b){ Line x=Line(a, b); root=add(root, x, xmn, xmx); } T get(Node *t, T l, T r, T val){ if(!t){ if(ismin) return ymx; else return -ymx; } T m=(l+r)/2; T ret=t->x.get(val); if(vall, l, m, val)); else ret=max(ret, get(t->l, l, m, val)); }else{ if(ismin) ret=min(ret, get(t->r, m, r, val)); else ret=max(ret, get(t->r, m, r, val)); } return ret; } T get(T val){ return get(root, xmn, xmx, val); } }; int n; ll c; const lll INFX=1e13; const lll INF=1e19; ll a[100010], b[100010]; int main() { cin>>n>>c; for(int i=0; i>a[i]>>b[i]; LiChaoTree cht1, cht2; cht1.add(0, 0); for(int i=0; i