func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     register int num = 0;     register char ch = getchar();     while (ch >  9  || ch <  0 ) ch = getchar();     while (ch <=  9  && ch >=  0 ) num = num * 10 + ch -  0 , ch = getchar();     return num;   }   int num[10];   inline void write(int x) {     register int cnt = 0;     if (!x) {       printf( 0 );       return;     }     while (x) num[++cnt] = x % 10, x /= 10;     while (cnt) putchar(num[cnt--] +  0 );   }   struct node {     int next, to, w;   } e[300020 * 2];   int n, m;   int head[300020], cnt;   int sz[300020], fa[300020], tag[300020], a[300020], tot, flag;   long long dth[300020], ans, mx[300020], dis[300020];   inline void adde(int x, int y, int w) {     e[++cnt].to = y;     e[cnt].next = head[x];     e[cnt].w = w;     head[x] = cnt;   }   void dfs(int x) {     for (int i = head[x]; i; i = e[i].next) {       if (e[i].to == fa[x]) continue;       dth[e[i].to] = dth[x] + e[i].w;       fa[e[i].to] = x;       dfs(e[i].to);     }   }   void dfs2(int x) {     sz[x] = 1;     for (int i = head[x]; i; i = e[i].next) {       if (e[i].to == fa[x] || tag[e[i].to]) continue;       dis[x] = max(dis[x], dis[e[i].to] + e[i].w);       dfs2(e[i].to);       sz[x] += sz[e[i].to];     }   }   void init() {     dfs(1);     int x = n;     while (x) tag[x] = 1, a[++tot] = x, x = fa[x];     for (register int i = 1; i <= tot + 1; i++) mx[i] = -1e16;     for (register int i = tot; i >= 1; i--) {       int x = a[i];       dfs2(x);       if (sz[x] > 1) mx[i] = max(mx[i + 1], dis[x] + dth[x]);       if (i < tot) {         ans = max(ans, dth[n] + dis[x] - dth[x] + mx[i + 1]);         if (sz[x] > 1)           ans = max(ans, dth[n] + dis[x] - dth[x] + dth[a[i + 1]]);         else if (i < tot - 1)           ans = max(ans, dth[n] + dis[x] - dth[x] + dth[a[i + 2]]);       }       if (sz[x] > 2) flag = 1;     }   }   int main() {     scanf( %d %d , &n, &m);     for (register int i = 1; i <= n - 1; i++) {       int x, y, w;       scanf( %d %d %d , &x, &y, &w);       adde(x, y, w), adde(y, x, w);     }     init();     while (m--) {       int l = read();       long long cur = min(dth[n], ans + l);       if (flag) cur = max(cur, dth[n]);       printf( %I64d n , cur);     }     return 0;   }   