dist[neighbour] = min(dist[neighbour], dist[current] + edge_weight)
// Reference: Competitive Programming 4
vector<int> dist(n, INF);
dist[0] = 0;
set<pair<int, int>> pq;
for (int i = 0; i < n; i++)
pq.emplace(dist[i], i);
while (!pq.empty()) {
auto front = *pq.begin();
int d = front.first, cur = front.second;
pq.erase(pq.begin());
for (auto item : graph[cur]) {
int v = item.first, w = item.second;
if (dist[cur] + w < dist[v]) {
pq.erase(pq.find({dist[v], v}));
dist[v] = dist[cur] + w;
pq.emplace(dist[v], v);
}
}
}
cout << dist[n - 1];