intread(){ int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { s = (s << 1) + (s << 3) + ch - '0'; ch = getchar(); } return s * w; }
signedmain(){ n = read(), m = read(); for (int i = 1; i <= n; i++) { h[i] = read(); fa[i] = i; } for (int i = 1; i <= m; i++) { int u = read(), v = read(), t = read(); if (h[u] >= h[v]) add(u, v, t); if (h[u] <= h[v]) add(v, u, t);
} dfs(1); cout << maxn << " "; sort(ed + 1, ed + cnt + 1, cmp); for (int i = 1; i <= cnt; i++) { if (find(ed[i].st) != find(ed[i].ed)) { merge(ed[i].st, ed[i].ed); ans += ed[i].dis; } } cout << ans << endl; return0; }