| 300 | } |
| 301 | |
| 302 | public static void main(String[] args) throws Exception { |
| 303 | FastReader in = new FastReader(System.in); |
| 304 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 305 | n = in.nextInt(); |
| 306 | m = in.nextInt(); |
| 307 | limitl = in.nextInt(); |
| 308 | limitr = in.nextInt(); |
| 309 | for (int i = 1; i <= m; i++) { |
| 310 | val[i] = in.nextInt(); |
| 311 | } |
| 312 | for (int i = 1, u, v, c; i < n; i++) { |
| 313 | u = in.nextInt(); |
| 314 | v = in.nextInt(); |
| 315 | c = in.nextInt(); |
| 316 | addEdge(u, v, c); |
| 317 | addEdge(v, u, c); |
| 318 | } |
| 319 | build(preTree, 0, n, 1); |
| 320 | build(curTree, 0, n, 1); |
| 321 | out.println(solve(getCentroid(1, 0))); |
| 322 | out.flush(); |
| 323 | out.close(); |
| 324 | } |
| 325 | |
| 326 | // 读写工具类 |
| 327 | static class FastReader { |