Problem:
JOI 国の買い物事情(Shopping in JOI Kingdom)
JOI 国には
N
個の町があり，それらの間は
M
本の双方向に通行可能な道路で結ばれている．
K
個の町にはショッピングモールがあり，国民は道路を通ってそれらの町のいずれかに行き買い物をする．
家の場所によっては，買い物に行くために長い距離を移動する必要があり，それは非常に不便である．国王はこの実情を把握するため，ショッピングモールのある町までの最短距離が家の場所によってどれだけ長くなりうるのかを調べることにした．家は道路の途中に建てられることもあるので(入力例1 の説明を参照)，この調査は非常に大変である．そこで国王は，優秀なプログラマーであるあなたに，調査を行うプログラムの作成を依頼した．
課題
道路の情報とショッピングモールのある町の情報が与えられるとき，ショッピングモールのある町からもっとも遠い道路上の点(端点も含む) までの距離を求めるプログラムを作成せよ．町の中を移動するのにかかる距離は無視してよい．
制限
2 ≤
N
≤ 3000     JOI 国の町の個数
1 ≤
M
≤ 100000 = 10
5
JOI 国の道路の本数
1 ≤
K
≤
N
ショッピングモールがある町の個数
1 ≤
l
i
≤ 1000
i
番目の道路の長さ
入力
標準入力から以下の入力を読み込め．
1 行目には整数
N
,
M
,
K
が空白区切りで書かれている．
N
はJOI 国の町の個数を，
M
はJOI 国の道路の本数を，i>K
はショッピングモールがある町の個数をそれぞれ表す．町には1, 2, ...,
N
の番号がつけられている．
続く
M
行は道路の情報を表す．
i
+ 1 行目(1 ≤
i
≤
M
) には整数
a
i
,
b
i
,
l
i
(1 ≤
a
i
≤
N
, 1 ≤
b
i
≤
N
, 1 ≤
l
i
≤ 1000) が空白区切りで書かれている．これは，
i
本目の道路が町
a
i
と町
b
i
を結んでおり，長さが
l
i
であることを表す．道路の両端が同じ町であることはない．また，任意の2 つの町
p
,
q
に対し，
p
と
q
を結ぶ道路は2 本以上存在しない．どの町からどの町へもいくつかの道路をたどって行くことができる．
続く
K
行はショッピングモールの情報を表す．
i
+
M
+1 行目(1 ≤
i
≤
K
) には1 つの整数
s
i
(1 ≤
s
i
≤
N
)が書かれている．これは町
s
i
にショッピングモールがあることを表す．
s
1
, ...,
s
K
の中に同じ値が2
回以上現れることはない．
出力
標準出力に，ショッピングモールのある町までの最短距離の最大値の小数点以下を四捨五入した整数1
つを出力せよ．
採点基準
採点用データのうち，配点の40% 分については，
K
= 1 を満たす．
入出力の例
入力例1
3 3 1
1 2 1
2 3 1
3 1 1
1
出力例1
2
入力例1 は次のような町を表す．道路の長さはすべて1 である．ショッピングモールは町1 にしかない．
ショッピングモールのある町までもっとも遠い点は，町2 と町3 を結ぶ道路上の，町2 から距離0.5 の位置にある点であり，ショッピングモールのある町までの距離は1.5 である．よって，それを四捨五入した値である2 を出力する．
入力例2
4 5 2
1 2 4
1 3 1
2 3 2
2 4 2
3 4 1
2
4
出力例2
3
問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include<iostream>
#include<functional>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>Q;
int n, m, k, a[100000], b[100000], c[100000], r[10000], dist[10000];
vector<pair<int, int>>x[10000];
void dijkstra() {
	for (int i = 1; i <= n; i++) dist[i] = 999999999;
	for (int i = 0; i < k; i++) { dist[r[i]] = 0; Q.push(make_pair(0, r[i])); }
	while (!Q.empty()) {
		int a1 = Q.top().first, a2 = Q.top().second; Q.pop();
		for (int i = 0; i < x[a2].size(); i++) {
			if (dist[x[a2][i].first] > a1 + x[a2][i].second) {
				dist[x[a2][i].first] = a1 + x[a2][i].second;
				Q.push(make_pair(dist[x[a2][i].first], x[a2][i].first));
			}
		}
	}
}
int main() {
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i]; 
		x[a[i]].push_back(make_pair(b[i], c[i]));
		x[b[i]].push_back(make_pair(a[i], c[i]));
	}
	for (int i = 0; i < k; i++)cin >> r[i];
	dijkstra();
	int maxn = 0;
	for (int i = 0; i < m; i++) {
		int R1 = min(dist[a[i]], dist[b[i]]);
		int R2 = (c[i] + abs(dist[a[i]] - dist[b[i]]) + 1) / 2;
		maxn = max(maxn, R1 + R2);
	}
	cout << maxn << endl;
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 7824
final_rank: 11

code_snippet: #include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

// 定数定義
const long long INF = 1e18; // 無限大を表す値
typedef pair<long long, int> pii; // (距離, 町の番号)のペア

// 道路を表す構造体
struct Road {
    int u; // 町u
    int v; // 町v
    int l; // 道路の長さ
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M, K;
    cin >> N >> M >> K;
    
    // 隣接リストの作成
    vector<vector<pair<int, int>>> adj(N, vector<pair<int, int>>());
    // 全ての道路を保存するためのベクター
    vector<Road> roads(M);
    
    // M本の道路の情報を入力
    for(int i = 0; i < M; ++i){
        int ai, bi, li;
        cin >> ai >> bi >> li;
        ai--; // 0-indexed に変換
        bi--; // 0-indexed に変換
        roads[i] = Road{ai, bi, li}; // 道路情報を保存
        adj[ai].emplace_back(bi, li); // 隣接リストに追加
        adj[bi].emplace_back(ai, li); // 双方向なので逆も追加
    }
    
    // ショッピングモールがある町のリスト
    vector<int> malls(K);
    for(int i = 0; i < K; ++i){
        cin >> malls[i];
        malls[i]--; // 0-indexed に変換
    }
    
    // 各町への最短距離を格納する配列
    vector<long long> dist(N, INF);
    
    // 優先度付きキュー（最小ヒープ）
    priority_queue<pii, vector<pii>, std::greater<pii>> pq;
    
    // ショッピングモールからの距離を0に設定し、キューに追加
    for(auto &s : malls){
        dist[s] = 0;
        pq.emplace(0, s);
    }
    
    // ダイクストラ法による最短距離の計算
    while(!pq.empty()){
        // 現在の最小距離と町の番号を取得
        pair<long long, int> current = pq.top();
        long long current_dist = current.first;
        int u = current.second;
        pq.pop();
        
        // 既により短い距離が確定している場合はスキップ
        if(current_dist > dist[u]) continue;
        
        // 隣接する町への距離を更新
        for(auto &edge : adj[u]){
            int v = edge.first;
            int w = edge.second;
            if(dist[v] > dist[u] + w){
                dist[v] = dist[u] + w;
                pq.emplace(dist[v], v);
            }
        }
    }
    
    // 各道路上の最短距離の最大値を求める
    double max_distance = 0.0;
    
    for(int i = 0; i < M; ++i){
        int u = roads[i].u;
        int v = roads[i].v;
        int l = roads[i].l;
        // 道路上の最遠点からの最短距離を計算
        double distance = (dist[u] + dist[v] + (long long)l) / 2.0;
        // 最大値を更新
        if(distance > max_distance){
            max_distance = distance;
        }
    }
    
    // 結果を四捨五入して整数にする
    int result = round(max_distance);
    cout << result << "\n";
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 7476
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
template<class T>
bool chmax(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p < q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}
template<class T>
bool chmin(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p > q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll N,M,K;
    cin>>N>>M>>K;
    vector<vector<pair<ll,ll>>> G(N);
    rep(i,M){
        ll U,V,W;
        cin>>U>>V>>W;
        U--;V--;
        G[U].push_back({V,W});
        G[V].push_back({U,W});
    }
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> Q;
    vll D(N,1e18);
    vb seen(N,false);
    rep(i,K){
        ll P;
        cin>>P;
        P--;
        D[P]=0;
        Q.push({0,P});
    }
    while(!Q.empty()){
        auto cn=Q.top();
        Q.pop();
        ll c=cn.first;
        ll n=cn.second;
        if(seen[n])continue;
        seen[n]=1;
        for(auto vw:G[n]){
            ll v=vw.first;
            ll w=vw.second;
            if(seen[v])continue;
            if(chmin(D[v],c+w)){
                Q.push({D[v],v});
            }
        }
    }
    ll an=0;
    rep(n,N){
        chmax(an,D[n]);
        for(auto vw:G[n]){
            ll v=vw.first;
            ll w=vw.second;
            ll dv=D[v];
            ll dn=D[n];
            if(dv<dn)swap(dv,dn);
            w-=(dv-dn);
            w=dv+(w+1)/2;
            chmax(an,w);
        }
    }
    cout<<an<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 9168
final_rank: 14

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,k; cin >> n >> m >> k;
    vector<vector<pair<int,int>>> g(n);
    for (int i = 0; i < m; ++i) {
        int x,y,z; cin >> x >> y >> z;
        x--; y--;
        g[x].push_back({y, z});
        g[y].push_back({x, z});
    }
    vector<int> d(n, 2e9);
    using P = pair<int,int>;
    priority_queue<P,vector<P>,greater<P>> pq;
    for (int i = 0; i < k; ++i) {
        int x; cin >> x; x--;
        d[x] = 0; pq.push({0, x});
    }
    while (pq.size()) {
        auto p = pq.top(); pq.pop();
        int x = p.second;
        if (d[x] != p.first) continue;
        for (auto to : g[x]) {
            if (d[to.first] > d[x]+to.second) {
                d[to.first] = d[x]+to.second;
                pq.push({d[to.first], to.first});
            }
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (auto t : g[i]) {
            int j = t.first;
            int mx = max(d[i], d[j]);
            int l = t.second-(max(d[i],d[j]) - min(d[i],d[j]));
            res = max(res, mx+(l+1)/2);
        }
    }
    cout << res << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 6376
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
using i32 = int;
using ld = long double;

int main() {
    i32 n, m, k; cin >> n >> m >> k;
    vector G(n + 1, vector(0, pair(0, 0)));
    vector es(m, tuple(0, 0, 0LL));
    for (i32 i = 0 ; i < m ; i++) {
        i32 a, b, l; cin >> a >> b >> l;
        G[a - 1].emplace_back(b - 1, l);
        G[b - 1].emplace_back(a - 1, l);
        es[i] = { a - 1, b - 1, l };
    }
    for (i32 _ = 0 ; _ < k ; _++) {
        i32 s; cin >> s;
        G[n].emplace_back(s - 1, 0);
    }
    const i32 sup = (1 << 30);
    vector ds(n + 1, sup);
    ds[n] = 0;
    priority_queue<pair<i32, i32>, vector<pair<i32, i32>>, greater<pair<i32, i32>>> que;
    que.emplace(0, n);
    while (que.size()) {
        auto [d, v] = que.top();
        que.pop();
        if (d > ds[v]) {
            continue;
        }
        for (auto [x, w] : G[v]) {
            if (ds[x] > d + w) {
                ds[x] = d + w;
                que.emplace(d + w, x);
            }
        }
    }
    i32 ans = *max_element(ds.begin(), ds.end());
    for (auto [a, b, w] : es) {
        if (ds[a] + w == ds[b] or ds[b] + w == ds[a]) {
            continue;
        }
        i32 val = ds[a] + (w + ds[b] - ds[a] + 1) / 2;
        ans = max(ans, val);
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 7720
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using i32 = int;
using ld = long double;

int main() {
    i32 n, m, k; cin >> n >> m >> k;
    vector G(n + 1, vector(0, pair(0, 0)));
    vector es(m, tuple(0, 0, 0LL));
    for (i32 i = 0 ; i < m ; i++) {
        i32 a, b, l; cin >> a >> b >> l;
        G[a - 1].emplace_back(b - 1, l);
        G[b - 1].emplace_back(a - 1, l);
        es[i] = { a - 1, b - 1, l };
    }
    for (i32 _ = 0 ; _ < k ; _++) {
        i32 s; cin >> s;
        G[n].emplace_back(s - 1, 0);
    }
    const i32 sup = (1 << 30);
    vector ds(n + 1, sup);
    ds[n] = 0;
    priority_queue<pair<i32, i32>, vector<pair<i32, i32>>, greater<pair<i32, i32>>> que;
    que.emplace(0, n);
    while (que.size()) {
        auto [d, v] = que.top();
        que.pop();
        if (d > ds[v]) {
            continue;
        }
        for (auto [x, w] : G[v]) {
            if (ds[x] > d + w) {
                ds[x] = d + w;
                que.emplace(d + w, x);
            }
        }
    }
    i32 ans = *max_element(ds.begin(), ds.end());
    for (auto [a, b, w] : es) {
        if (ds[a] + w == ds[b] or ds[b] + w == ds[a]) {
            continue;
        }
        ld l = 0.0l, r = (ld)w;
        for (i32 _ = 0 ; _ < 80 ; _++) {
            ld m = (l + r) / 2.0l;
            if (ds[a] + m > ds[b] + ((ld)w - m)) {
                r = m;
            }
            else {
                l = m;
            }
        }
        ans = max(ans, (i32)round(ds[a] + l));
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 80
memory_kb: 7700
final_rank: 12

code_snippet: #line 1 "solve/main.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

#line 2 "lib/utility/type_alias.hpp"

#line 4 "lib/utility/type_alias.hpp"

using u64 = std::uint64_t;
using u32 = std::uint32_t;
using u16 = std::uint16_t;
using u8 = std::uint8_t;

using i64 = std::int64_t;
using i32 = std::int32_t;
using i16 = std::int16_t;
using i8 = std::int8_t;

using usize = std::size_t;
using isize = std::ptrdiff_t;

constexpr i64 operator"" _i64(unsigned long long num) { return i64(num); }

constexpr u64 operator"" _u64(unsigned long long num) { return u64(num); }
#line 33 "solve/main.cpp"

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...)                                                    \
  std::cerr << "LINE: " << __LINE__ << "  [" << #__VA_ARGS__ << "]:", \
      debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cerr << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num, typename Func = std::multiplies<Num>>
constexpr Num mypow(Num a, u64 b, Num id = 1, Func mul = Func()) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}

/* template end */

using P = std::pair<i64,i64>;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  i64 n,m,k;
  std::cin>>n>>m>>k;

  std::vector<std::vector<P>> graph(n);

  rep(i,0,m){
    i64 a,b,l;
    std::cin>>a>>b>>l;
    a--;b--;
    graph[a].emplace_back(b,l);
    graph[b].emplace_back(a,l);
  }

  constexpr i64 INF = 1e15;

  std::vector<i64> dist(n,INF);
  std::priority_queue<P,std::vector<P>,std::greater<P>> pq;

  rep(i,0,k){
    i64 a;
    std::cin>>a;
    a--;
    dist[a] = 0;
    pq.emplace(0,a);
  }

  while (!pq.empty()){
    auto [d,now] = pq.top();pq.pop();

    if(d > dist[now])continue;

    for(const auto& [next,cost]:graph[now]){
      if(dist[next] > dist[now] + cost){
        dist[next] = dist[now] + cost;
        pq.emplace(dist[next],next);
      }
    }
  }

  debug(dist);

  i64 ans = 0;
  rep(i,0,n){
    chmax(ans,dist[i]);
    for(const auto& [next,cost]: graph[i]){
      auto [a,b] = P(dist[i],dist[next]);
      if(a<b)std::swap(a,b);

      if(a >= b+cost)
        chmax(ans,b+cost);
      else{
        if((a+b+cost) % 2 == 0)
          chmax(ans,(a+b+cost)/2);
        else
          chmax(ans,(a+b+cost+1)/2);
      }
    }
  }

  std::cout<<ans<<"\n";
  

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 8992
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
//typedef int ll;
typedef pair<ll, ll> P;
const long long INF = 1e17;
template <typename T>
void input_arr(vector<T>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
}
template <typename T, typename Q>
void input_arr(vector<pair<T, Q>>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
}
template <typename T>
void input_arr(vector<vector<T>>& A, ll H, ll W) {
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
}
template<typename T = ll>
struct Edge {
    ll from, to; T cost;
    Edge (ll from, ll to, T cost = 1) : from(from), to(to), cost(cost) {}
};
template<typename T = ll>
struct Graph {
    vector<vector<Edge<T>>> G;
    Graph() = default;
    explicit Graph(ll N) : G(N) {}
    size_t size() const {
        return G.size();
    }
    void add_edge(ll from, ll to, T cost = 1, bool direct = false) {
        G[from].emplace_back(from, to, cost);
        if (!direct) G[to].emplace_back(to, from, cost);
    }
    void read(ll M, ll padding = -1, bool weight = false, bool direct = false) {
        for (ll i = 0; i < M; i++) {
            ll a, b; cin >> a >> b;
            a += padding;
            b += padding;
            T c = T(1);
            if (weight) cin >> c;
            add_edge(a, b, c, direct);
        }
    }
    vector<Edge<T>> &operator[](const int &k) {
        return G[k];
    }
};
void dijkstra(const Graph<long long>& G, int s, vector<long long>& dis) {
    int N = G.size();
    priority_queue<P, vector<P>, greater<P>> pq;
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (auto& e : G.G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}
void solve() {
    ll N, M, K; cin >> N >> M >> K;
    Graph<ll> G(N);
    vector<P>edge(M);
    vector<ll>wei(M);
    for (ll i = 0; i < M; i++) {
        ll u, v, c; cin >> u >> v >> c;
        u--; v--;
        G.add_edge(u, v, c, false);
        edge[i] = {u, v};
        wei[i] = c;
    } 
    vector<ll>dist(N, INF);
    for (ll i = 0; i < K; i++) {
        ll s; cin >> s; s--;
        dijkstra(G, s, dist);
    } 
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans = max(ans, dist[i]);
    }
    for (ll i = 0; i < M; i++) {
        if (abs(dist[edge[i].first] - dist[edge[i].second]) >= wei[i]) continue;
        ans = max(ans, (dist[edge[i].first] + dist[edge[i].second] + wei[i] + 1) / 2);
    }
    cout << ans << endl;
}
int main() {
    ll T=1; //cin >> T;
    while (T--) solve();
}
accuracy: 1
time_ms: 140
memory_kb: 14276
final_rank: 18

code_snippet: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define popcount(v) __builtin_popcount(v)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
using namespace std;
using ll = long long;
template<class T> using rpriority_queue = priority_queue<T, vector<T>, greater<T>>;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=1LL<<60;
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T,class U,class V>void scan(tuple<T,U,V>& p){scan(get<0>(p));scan(get<1>(p));scan(get<2>(p));}
template<class T, size_t size> void scan(array<T, size>& a){ for(auto&& i : a) scan(i);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){return (a+b-1)/b;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n,m,k);
    vector<vector<pair<int,int>>> g(n);
    int u,v,c;
    rep(i,m){
        in(u,v,c);
        g[--u].emplace_back(--v,c);
        g[v].emplace_back(u,c);
    }
    vector<int> dist(n,INF);
    rpriority_queue<pair<int,int>> pq;
    rep(i,k){
        in(v);
        dist[--v]=0;
        pq.push({0,v});
    }
    while(!pq.empty()){
        tie(c,v)=pq.top();
        pq.pop();
        for(auto p:g[v]){
            if(c+p.second>=dist[p.first])continue;
            dist[p.first]=c+p.second;
            pq.push({c+p.second,p.first});
        }
    }
    int ans=0;
    for(v=0;v<n;v++){
        chmax(ans,dist[v]);
        for(auto p:g[v]){
            if(dist[p.first]<dist[v])continue;
            chmax(ans,dist[p.first]+(int)updivide(p.second-(dist[p.first]-dist[v]),2));
        }
    }
    out(ans);
}
accuracy: 1
time_ms: 10
memory_kb: 6548
final_rank: 6

code_snippet: #include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define puts(x) cout << (x) << "\n"
using namespace std;
int input() {
	int r; cin >> r; //scanf("%lld", &r); 
	return r;
}
int n, m, k, cost[3340], a[123456], b[123456], l[123456];
vector<pair<int, int>> graph[3340];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;
signed main() {
	cin >> n >> m >> k;
	for1(i, m) {
		cin >> a[i] >> b[i] >> l[i];
		graph[a[i]].push_back(mp(b[i], l[i]));
		graph[b[i]].push_back(mp(a[i], l[i]));
	}
	for1(i, n) cost[i] = m * 1010;
	while (k--) {
		int c1[3340];
		for1(i, n) c1[i] = m * 1010;
		pq.push(mp(0, input()));
		while (pq.size()) {
			int cost1 = pq.top().first, x1 = pq.top().second;
			pq.pop();
			if (cost1 > c1[x1])continue;
			c1[x1] = cost1;
			for (pair<int, int>p1 : graph[x1]) {
				if (cost[p1.first] > cost1 + p1.second) {
					cost[p1.first] = cost1 + p1.second;
					pq.push(mp(cost[p1.first], p1.first));
				}
			}
		}
		for1(i, n) cost[i] = min(cost[i], c1[i]);
	}
	int ans = 0;
	for1(i, m) {
		int p = cost[a[i]], q = cost[b[i]];
		if (p > q)swap(p, q);
		ans = max(ans, (l[i] - q + p + 1) / 2 + q);
	}puts(ans);
}
accuracy: 1
time_ms: 160
memory_kb: 11080
final_rank: 17

code_snippet: #include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
struct edge {
	int to, cost;
};
struct state {
	int pos, cost;
	bool operator<(const state& s) const {
		return cost > s.cost;
	}
};
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c; --a, --b;
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
	}
	vector<int> dist(N, inf);
	priority_queue<state> que;
	for (int i = 0; i < K; ++i) {
		int x;
		cin >> x; --x;
		dist[x] = 0;
		que.push(state{ x, 0 });
	}
	vector<bool> vis(N, false);
	while (!que.empty()) {
		int u = que.top().pos; que.pop();
		if (vis[u]) continue;
		for (edge e : G[u]) {
			if (dist[e.to] > dist[u] + e.cost) {
				dist[e.to] = dist[u] + e.cost;
				que.push(state{ e.to, dist[e.to] });
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (edge e : G[i]) {
			ans = max(ans, dist[i] + dist[e.to] + e.cost);
		}
	}
	cout << (ans + 1) / 2 << endl;
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 5964
final_rank: 4

code_snippet: #include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

struct edge { ll to, cost; };
typedef pair<ll, ll>P; //firstは最短距離、secondは頂点番号
ll d[213456];//始点sから終点tまでのコストd[t]
vector<edge> G[213456];//コスト
void dijkstra(vector<ll> s) {
	//greater<P>を指定→firstが小さい順
	priority_queue<P, vector<P>, greater<P> >que;
	fill(d, d + 213456, INF);//←TLE気を付ける
	rep(i, s.size()) {
		d[s[i]] = 0; que.push(P(0, s[i]));
	}
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) { continue; }
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll n, m, k; cin >> n >> m >> k;
	vector<vector<ll>> hen(m, vector<ll>(3));
	rep(i, m) {
		ll a, b, l; cin >> a >> b >> l;
		G[a].push_back({ b, l }); G[b].push_back({ a, l });
		hen[i][0] = a; hen[i][1] = b; hen[i][2] = l;
	}

	vector<ll> super(k);
	rep(i, k) {
		cin >> super[i];
	}
	dijkstra(super);

	ll ans = 0;
	rep(i, m) {
		ll mi = min(d[hen[i][0]], d[hen[i][1]]);
		ll ma = max(d[hen[i][0]], d[hen[i][1]]);
		//cout << ma << ' ' << mi << endl;
		hen[i][2] -= (ma - mi);
		ans = max(ans, ma + ((hen[i][2] + 1) / 2));
	}
	cout << ans << endl;
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 20952
final_rank: 20

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

#define INF (1LL<<61)

//ここから編集
vector<vector<pair<int, int>>> g(3010);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, M, K; cin >> N >> M >> K;

  REP(i,M){
    int a, b, l;
    cin >> a >> b >> l;
    a--; b--;
    g[a].emplace_back(b, l);
    g[b].emplace_back(a, l);
  }
  vector<int> s(K);
  vector<int> dist(N, INT_MAX);
  map<int, int> mp;
  priority_queue<PII, vector<PII>, greater<PII>> pq;

  REP(i,K){
    cin >> s[i];
    s[i]--;
    dist[s[i]] = 0;
    pq.push({0, s[i]});
  }

  

  while(pq.size()){
    auto p = pq.top();
    pq.pop();

    int cost = p.first;
    int v = p.second;
    if(dist[v] < cost) continue;

    for(auto e: g[v]){
      int u = e.first;
      int cc = e.second;
      if(dist[u] > dist[v] + cc){
        dist[u] = dist[v] + cc;
        pq.push({dist[u], u});
      }
    }
  }

  int mx = 0;
  for(int i=0; i<N; i++){
    mx = max(mx, dist[i]);
  }

  vector<int> pos;
  for(int i=0; i<N; i++){
    if(mx == dist[i]) pos.push_back(i);
  }

  int ans = mx;
  for(int p=0; p<N; p++){
    int v = p;
    for(int i=0; i<g[p].size(); i++){
      
      int u = g[p][i].first;
      if(dist[v] < dist[u]) continue;
      if(dist[u] == dist[v]){
        ans = max(ans, min(dist[u] + (int)round( (double)g[p][i].second/2.0), dist[v] + (int)round( (double)g[p][i].second/2.0)));
        continue;
      }

      double t = 0;
      /* v -> u */
      while(t <= g[p][i].second){
        if(dist[v] > dist[u]){
          ans = max(ans, min(dist[u] + (int)round(t), dist[v] + (int)round( (double)g[p][i].second - t)));
          t += 0.5;
        }
        
      }
    }
  }
  cout << ans << endl;
  return 0;
}
accuracy: 1
time_ms: 1280
memory_kb: 6020
final_rank: 19

code_snippet: #include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

struct edge {
    edge(int t, ll c) : to(t), cost(c) {}
    int to;
    ll cost;
};

void dijkstra(int s, vector<ll> &d, vector<vector<edge>> &G) {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    fill(All(d), LINF);
    d[s] = 0;
    que.push(make_pair(0, s));

    while(!que.empty()) {
        pll p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first)
            continue;
        for(auto e : G[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<edge>> G(N + 1, vector<edge>());
    vector<pair<pii, int>> edges(M);
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back(edge(b, c));
        G[b].push_back(edge(a, c));
        edges[i] = MP(MP(a, b), c);
    }

    rep(i, K) {
        int k;
        cin >> k;
        k--;
        G[N].push_back(edge(k, 0));
    }
    vector<ll> dist(N + 1);
    dijkstra(N, dist, G);
    ll res = 0;
    rep(i, N) { res = max(res, dist[i]); }
    rep(i, M) {
        int a = edges[i].first.first;
        int b = edges[i].first.second;
        ll c = edges[i].second;
        res = max(res, (dist[a] + dist[b] + c + 1) / 2);
    }
    cout << res << endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 9896
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
struct Edge{
    int u,v,cost;
};
vector<P> graph[110000];
int dist[110000];
int dist2[110000];
const int INF = 1001001001001LL;
signed main()
{
    int n,m,k;cin >> n >> m >> k;
    rep(i,m){
        int a,b,l;cin >> a >> b >> l;
        a--;b--;
        graph[a].push_back(P(b,l));
        graph[b].push_back(P(a,l));
    }
    priority_queue<P,vector<P>,greater<P>> q;
    rep(i,110000){
        dist[i] = INF;
        dist2[i] = INF;
    }
    rep(i,k){
        int s;cin >> s;
        s--;
        dist[s] = 0;
        dist2[s] = 0;
        q.emplace(0,s);
    }
  
    while(q.size()){
        auto p = q.top();q.pop();
        int v = p.second,d = p.first;
        if(dist2[v] < d)continue;
        for(auto next:graph[v]){
            int d2 = d+next.second;
            if(dist[next.first] > d2){
                swap(dist[next.first],d2);
                q.push(P(dist[next.first],next.first));
            }
            if(dist2[next.first] > d2 && dist[next.first] < d2){
                dist2[next.first] = d2;
                q.push(P(dist2[next.first],next.first));
            }

            
        }
    }

    int ans = 0;
    rep(i,n)rep(j,graph[i].size()){
        auto hoge = graph[i][j];
        int res = (dist[i]  + dist[hoge.first]+1 + hoge.second)/2;
        ans = max(ans,res);

    }
    cout << ans << endl;




    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 10196
final_rank: 16

code_snippet: // #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

struct Elem {
    int cur; ll cost;
    Elem() {}
    Elem(int cur_, ll cost_) : cur(cur_), cost(cost_) {}
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};

ll dist[110010];
int main() {
    int N, M, K; scanf("%d%d%d", &N, &M, &K);

    int V = N;
    vector< vector< pair<int, int> > > G(V);
    for(int i=0; i<M; i++) {
        int u, v, c; scanf("%d%d%d", &u, &v, &c);
        u--; v--;
        G[u].emplace_back(v, c);
        G[v].emplace_back(u, c);
    }

    fill(dist, dist + V, LONGINF);
    priority_queue<Elem> que;
    for(int i=0; i<K; i++) {
        int v; scanf("%d", &v);
        v--;
        dist[v] = 0;
        que.emplace(v, 0);
    }

    while(que.size()) {
        Elem elem = que.top(); que.pop();
        int cur = elem.cur; ll cost = elem.cost;
        if(dist[cur] < cost) continue;
        for(auto e : G[cur]) {
            int to, d; tie(to, d) = e;
            if(dist[to] > cost + d) {
                dist[to] = cost + d;
                que.emplace(to, dist[to]);
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<V; i++) {
        chmax(ans, dist[i]);
        for(auto e : G[i]) {
            int cur = i, to = e.first, d = e.second;
            ll x = (dist[to] - dist[cur] + d + 1) / 2;
            chmax(ans, dist[cur] + x);
        }
    }
    printf("%lld\n", ans);
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 6000
final_rank: 1

code_snippet: #include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> l(M),r(M),c(M);
    vector<vector<P>> G(N);
    for(int i=0; i<M; i++){
        cin >> l[i] >> r[i] >> c[i];
        l[i]--;r[i]--;
        G[l[i]].emplace_back(r[i],c[i]);
        G[r[i]].emplace_back(l[i],c[i]);
    }
    priority_queue<P,vector<P>,greater<P>> que;
    vector<int> dist(N,inf);
    for(int i=0; i<K; i++){
        int a;
        cin >> a;
        a--;
        dist[a] = 0;
        que.emplace(0,a);
    }
    while(que.size()){
        int v = que.top().second;
        int cost = que.top().first;
        que.pop();
        if(cost > dist[v]) continue;
        for(auto nv: G[v]){
            if(nv.second + cost < dist[nv.first]){
                dist[nv.first] = nv.second + cost;
                que.emplace(dist[nv.first],nv.first); 
            }
        }
    }
    // for(int i=0; i<N; i++){
    //     cout << dist[i] << enld;
    // }
    int ans = 0;
    for(int i=0; i<N; i++){
        chmax(ans,dist[i]);
        for(auto nv: G[i]){
            int v = nv.first;
            int t = (dist[v]+dist[i]+nv.second+1)/2;
            chmax(ans,t);
        }
    }
    cout << ans << enld;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 7152
final_rank: 7

code_snippet: #include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> l(M),r(M),c(M);
    vector<vector<P>> G(N);
    for(int i=0; i<M; i++){
        cin >> l[i] >> r[i] >> c[i];
        l[i]--;r[i]--;
        G[l[i]].emplace_back(r[i],c[i]);
        G[r[i]].emplace_back(l[i],c[i]);
    }
    priority_queue<P,vector<P>,greater<P>> que;
    vector<int> dist(N,inf);
    for(int i=0; i<K; i++){
        int a;
        cin >> a;
        a--;
        dist[a] = 0;
        que.emplace(0,a);
    }
    while(que.size()){
        int v = que.top().second;
        int cost = que.top().first;
        que.pop();
        if(cost > dist[v]) continue;
        for(auto nv: G[v]){
            if(nv.second + cost < dist[nv.first]){
                dist[nv.first] = nv.second + cost;
                que.emplace(dist[nv.first],nv.first); 
            }
        }
    }
    // for(int i=0; i<N; i++){
    //     cout << dist[i] << enld;
    // }
    int ans = 0;
    for(int i=0; i<N; i++){
        chmax(ans,dist[i]);
        for(auto nv: G[i]){
            int v = nv.first;
            int t = dist[i]+(dist[v]-dist[i]+nv.second+1)/2;
            chmax(ans,t);
        }
    }
    cout << ans << enld;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 7232
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct edge{
    int len;
    int to;
    edge(){}
    edge(int len,int to):len(len),to(to){}
};

int main() {
    using graph = vector<vector<edge>>;

    int n,m,k;
    cin>>n>>m>>k;

    graph G(n);
    for(int i = 0;i < m;++i) {
        int a,b,l;
        cin>>a>>b>>l;
        --a;--b;
        G[a].emplace_back(l,b);
        G[b].emplace_back(l,a);
    }

    priority_queue<pair<int,int>> pq;
    vector<int> mdist(n,300000000);

    for(int i = 0;i < k;++i) {
        int a;
        cin>>a;
        --a;
        pq.emplace(0,a);
        mdist[a]=0;
    }


    while(!pq.empty()) {
        auto t=pq.top();
        pq.pop();
        int tl=-t.first;
        int tv=t.second;

        for(auto px:G[tv]) {
            int ndist=tl+px.len;
            if(mdist[px.to]<ndist)continue;
            mdist[px.to]=ndist;
            pq.emplace(-ndist,px.to);
        }
    }

    int ld=0;
    for(int i = 0;i < n;++i) {
//cerr<<mdist[i]<<endl;
        ld=max(ld,mdist[i]);
    }

    for(int i = 0;i < n;++i) {
        for(auto e:G[i]) {
            //if(abs(mdist[i]-mdist[e.to])==e.len)continue;

            int a=mdist[i];
            int b=mdist[e.to];
            int l=e.len;

            if(a<b)swap(a,b);
            int td=b+l-a;
            td=(td+1)/2;
            ld=max(ld,td+a);
        }
    }
    cout<<ld<<endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 5948
final_rank: 3

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
const int inf = 1e9;
const double EPS = 1e-8;

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<pii>> adj(n);
    for(int i=0; i<m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        adj[a].emplace_back(b, c);
        adj[b].emplace_back(a, c);
    }
    vector<int> s(k);
    for(int i=0; i<k; i++){
        cin >> s[i];
        s[i]--;
    }

    priority_queue<pii> wait;
    vector<int> mincost(n, inf);
    for(int i: s){
        mincost[i] = 0;
        wait.push(pii(0, i));
    }
    while(!wait.empty()){
        int cost = -wait.top().first;
        int pos = wait.top().second;
        wait.pop();
        if(cost > mincost[pos]) continue;
        for(auto next: adj[pos]){
            int npos = next.first;
            int ncost = next.second +cost;
            if(ncost < mincost[npos]){
                mincost[npos] = ncost;
                wait.push(pii(-ncost, npos));
            }
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(auto p: adj[i]){
            int j = p.first;
            int d = p.second;
            int diff = abs(mincost[i] -mincost[j]);
            if(diff == d){
                ans = max(ans, max(mincost[i], mincost[j]));
            }else{
                ans = max(ans, max(mincost[i], mincost[j]) +(d-diff+1)/2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 5972
final_rank: 5