#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> usingnamespacestd; structedge{ int u, v; int w; } ; edge e[200002]; int fa[200002]; boolcmp(edge a, edge b){ if (a.w<b.w) return1; elsereturn0; } intfind(int n){ if (fa[n] == 0) return n; elsereturn find(fa[n]); } intmax(int a, int b){ return a > b ? a : b; } boolun(int a, int b){ a = find(a); b = find(b); if (a == b) return0; if (a<b) fa[b] = a; else fa[a] = b; return1; } intmain(){ int n, p; int sum, ct; // scanf("%d%d", &n, &p); cin >> n >> p; for (int i = 1; i <= p; i++) { // scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w); cin >> e[i].u >> e[i].v >> e[i].w; } sort(e + 1, e + 1 + p, cmp); memset(fa, 0, sizeof(fa)); sum = 0; ct = 1; int tot = 0; int maxa = 0; for (int i = 1; i <= p; i++) { if (un(e[i].u, e[i].v)) { // sum += e[i].w; tot++; maxa = max(maxa,e[i].w); ct++; } if (ct == n) break; } printf("%d %d", tot,maxa); return0; }