#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>k; vector t(n),d(n); for(Int i=0;i>t[i]>>d[i]; auto check= [&](Int x){ Int lst=-k; for(Int i=0;it[i]) return 0; lst=t[i]; } return 1; }; Int l=-1,r=1e9+100; while(l+1>1; if(check(m)) r=m; else l=m; } cout< dp(n+1,-INF); dp[0]=0; for(Int i=0,p=-1;i