import sys sys.setrecursionlimit(10**7) def main(): N, M = map(int, input().split()) U = [int(input()) for _ in range(N)] G = [[] for _ in range(N)] for _ in range(N-1): A,B,C = map(int, input().split()) G[A].append([B, C]) G[B].append([A, C]) dp = [[0]*(M+1) for _ in range(N)] def dfs(x, par=-1): seen[x] = 1 dp[x][0] = U[x] for nx, t in G[x]: if nx==par: continue dfs(nx, x) for m in range(M+1)[::-1]: for mm in range(M+1): T = m+mm+2*t if T