#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>N; int K;cin>>K; int sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy; for(int i=1;i<=N;i++){ cin>>X[i]>>Y[i]; } X[0]=sx; Y[0]=sy; X[N+1]=gx; Y[N+1]=gy; int left=0,right=3e5; while(right-left>1){ int mid=(left+right)/2; for(int i=0;i mi=mp(INF,INF); for(int i=0;i