#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long typedef vector VI; typedef pair pii; #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i > dp; //vector > > vvvi; //dp=vector >(N, vector(M,0)); //vector > v; //v.push_back(make_pair(x,y)); //priority_queue, greater > q2; int N, M; int V[210]; struct edge { int to, cost; }; vector G[210]; int dp[210][2010]; /*void dfs(int cu,int pa,int time,int val) { REP(i, G[cu].size()) { int to = G[cu][i].to; int cost = G[cu][i].cost; cout << cu << " " << to << " " << time + cost << endl; if (!vis[to]) { cost *= 2; val += V[to]; vis[to] = true; } //if (to == pa)continue; //cout <= 0; j--) { eREP(k, M) { int t = j + c * 2 + k; if (t <= M)dp[cu][t] = max(dp[cu][t], dp[cu][j] + dp[e.to][k]); } } } } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; REP(i, N)cin >> V[i]; REP(i, N - 1) { int a, b, c; cin >> a >> b >> c; edge e; e.to = a; e.cost = c; G[b].push_back(e); e.to = b; G[a].push_back(e); } dfs(0, -1); int ans = 0; eREP(i, M) { ans = max(ans, dp[0][i]); //cout << i<<" "<