# bzoj4152 [AMPPZ2014]The Captain

## Sample

### Sample Input

5
2 2
1 1
4 5
7 1
6 7


### Sample Output

2


## Solution

#include<bits/stdc++.h>
using namespace std;

#define N 200001
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define ll long long
#define pli pair<ll, int>

int x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (!(ch ^ '-')) flag = -1; ch = getchar(); }
while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - '0', ch = getchar(); return x * flag;
}

struct point { int x, y, id; }a[N];
bool cmpx(const point& p1, const point& p2) { return p1.x < p2.x; }
bool cmpy(const point& p1, const point& p2) { return p1.y < p2.y; }
ll dis[N];
bool vis[N];
priority_queue<pli, vector<pli>, greater<pli> > q;
struct edge{ int v, next; ll w; }e[N << 2];
inline void insert(int u, int v, ll w) { e[++tot].v = v, e[tot].w = w, e[tot].next = head[u], head[u] = tot; }
#define add(u, v, w) insert(u, v, w), insert(v, u, w)

void dijkstra() {
rep(i, 2, n) dis[i] = (1ll << 62ll);
q.push(make_pair(0, 1));
while (!q.empty()) {
int u = q.top().second; q.pop();
if (vis[u]) continue; vis[u] = 1;
for (int i = head[u], v; i; i = e[i].next) if (dis[v = e[i].v] > dis[u] + e[i].w)
dis[v] = dis[u] + e[i].w, q.push(make_pair(dis[v], v));
}
}

int main() {