#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=1e9+7; struct edge{ int to; int cost; edge(int to_,int cost_):to(to_),cost(cost_){}; }; int main(){ int N,K; cin>>N>>K; vector x(N+2),y(N+2); cin>>x[0]>>y[0]>>x[N+1]>>y[N+1]; for(int i=1;i<=N;i++){ cin>>x[i]>>y[i]; } const int inf=1<<30; int ub=inf;//必ず到達が可能 int lb=-1; while(ub-lb>1){ int mid=(ub+lb)/2; //cout<<"mid="<> G(N+2); for(int i=0;i dp(N+10,inf);//dp[i]=iに到達するまでにdp[i]個のあかりを消費する priority_queue,greater

> pq; pq.emplace(0,0); while(!pq.empty()){ auto [d,v]=pq.top(); pq.pop(); if(dp[v]<=d) continue; //dp[v]>d dp[v]=d; for(edge e:G[v]){ if(dp[e.to]>(dp[v]+e.cost)){ pq.emplace(dp[v]+e.cost,e.to); } } } /* for(int i=0;i<=N+2;i++){ cout<<"dp["<K){ //家に到達できない場合 lb=mid; }else{ //家に到達できる ub=mid; } */ } cout<