AK and City Networks
CodeChefOpen on judge ↗
AK works in a logistics company, and he is assigned with a task to build a road network between $N$ cities. The size of a city is $P_i$ and AK would like ot build $N - 1$ bidirectional roads connecting two cities such that any city can reached from any other city. Assuming that the cost of building a road between $ith$ and $jth$ city is $abs(i - j) * D + P_i + P_j$. Find the minimum possibl
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.
Sign in to chat with the tutor and save your progress.
Sign in to start