#include using namespace std; struct UnionFind { vector par; vector size; UnionFind(int n) { par.resize(n); size.resize(n,1); for(int i = 0; i < n; i++) { par[i] = i; } } int find(int x) { if(par[x] == x) { return x; } return par[x] = find(par[x]); } bool same(int x, int y) { return find(x) == find(y); } int consize(int x) { return size[find(x)]; } void unite(int x, int y) { x = find(x); y = find(y); if(x == y) { return; } if(size[x] < size[y]) { par[x] = y; size[y] += size[x]; } else { par[y] = x; size[x] += size[y]; } } }; bool f(pair>x,pair>y) { if(x.first.size() < y.first.size()) { return true; } if(x.first.size() > y.first.size()) { return false; } if(x.first <= y.first) { return true; } return false; } int main() { int N; cin >> N; vector>>tmp(N*(N-1)/2); for(int i = 0; i < N*(N-1)/2; i++) { cin >> tmp[i].second.first >> tmp[i].second.second >> tmp[i].first; tmp[i].second.first--; tmp[i].second.second--; } sort(tmp.begin(),tmp.end(),f); UnionFind uf(N); for(int i = 0; i < tmp.size(); i++) { uf.unite(tmp[i].second.first,tmp[i].second.second); if(uf.consize(0) == N) { cout << tmp[i].first << endl; return 0; } } }