int w(int current_time){ current_time = current_time % 1440; for (int i = 0; i < t.size(); ++i) if(current_time >= t[i].second.first && current_time < t[i].second.second) return t[i].first; return -1; }
lld kruskal(lld idx) { UnionFind UF(n); vii MST; //Contiene las aristas del MST sort(edges.begin(), edges.end()); lld mx = -INF; for (lld i = idx; i < edges.size(); i++) { lld w = edges[i].fst; lld a = edges[i].snd.fst; lld b = edges[i].snd.snd; if (!UF.isSameSet(a, b)) { MST.push_back(edges[i].snd); mx = max(mx, w); UF.Union(a, b); } } //Existencia de MST: return (UF.numSet() != 1) ? -1 : mx; // costo del MST }
void print (viii& p) { for (int i=0; i<p.size(); i++) printf (" %d %d-%d\n", p[i].first, p[i].second.first, p[i].second.second); printf("---\n"); }