#include #include using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; int main(){ int n, k; cin >> n >> k; n += 2; int sx, sy; cin >> sx >> sy; int gx, gy; cin >> gx >> gy; vector x(n), y(n); for (int i=0; i> x[i+1] >> y[i+1]; } x[0] = sx; y[0] = sy; x[n-1] = gx; y[n-1] = gy; int ub = 300000; int lb = 0; while (ub - lb > 1){ int targ = (ub + lb) / 2; vector ikeru(n, vector>(0)); for (int i=0; i d(n, 1e9); priority_queue> pq; pq.push(pair(0, 0)); d[0] = 0; while(!pq.empty()){ auto [tmp, i] = pq.top(); pq.pop(); tmp = -tmp; if (tmp > d[i]) continue; for (auto [j, dist] : ikeru[i]){ int res = tmp + dist; if (res < d[j]){ d[j] = res; pq.push(pair(-res, j)); } } } if (d[n-1] <= k){ ub = targ; }else{ lb = targ; } } cout << ub << endl; }