#include #include #include using namespace std; int N,M,K,S,T; int a[2<<17],b[2<<17],c[2<<17]; long dist[2<<17]; vector >X[2<<17]; main() { scanf("%d%d%d%d%d",&N,&M,&K,&S,&T); X[N-1].push_back(make_pair(T,-M-1)); dist[M+1]=1e18; for(int i=0;i++=0) { now=min(now,X[i][j].second); } else { int id=-X[i][j].second; dist[id]=min(dist[id],now); } } now=1e18,pre=1e9; for(int j=n;j--;) { now+=pre-X[i][j].first; pre=X[i][j].first; if(X[i][j].second>=0) { now=min(now,X[i][j].second); } else { int id=-X[i][j].second; dist[id]=min(dist[id],now); } } if(i+1