← All problemsSign in

Cheapest Office

CodeChefRating 2929Open on judge ↗

There is a tech park, which consists of $N$ rooms, numbered $1, 2, \ldots, N$. The $i$-th room has a cost of $A_i$ associated with it. There are $M$ bi-directional passages between these rooms. Chef wants to create an office in this tech park, for which she will select exactly $K$ out of these $N$ rooms. These $K$ rooms must be selected such that every selected room is reachable from every other

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start