#include using namespace std; struct I{ I(){ ios::sync_with_stdio(false);cin.tie(0); } }init; typedef vector V; typedef vector Graph;/*木を構築 Gは木じゃないとだめ*/ /*G:元の隣接リスト P:空の親ノード表 C:空の子ノード隣接リスト*/ void make_tree(int v, Graph &G,Graph &cost, int p, Graph &C,Graph &cc) { for (int i=0;i>N>>M; V U(N); for(auto &v:U)cin>>v; Graph g(N),tree(N),cost(N),cww(N); for(int i=1;i>A>>B>>C; g[A].push_back(B); cww[A].push_back(C); g[B].push_back(A); cww[B].push_back(C); } make_tree(0,g,cww,0,tree,cost); V dp=dfs(0,tree,cost,U); int res=0; for(int i=0;i<=M/2;i++)res=max(res,dp[i]); cout<