← All problemsSign in

Sum of distances

CodeChefRating 2880Open on judge ↗

There is a directed acyclic graph with N vertices. The vertices are numbered from 1 to N. For every 1 ≤ i ≤ N-1, there is an edge from vertex i to vertex i+1, which has weight ai. For every 1 ≤ i ≤ N-2, there is an edge from vertex i to vertex i+2, which has weight bi. For every 1 ≤ i ≤ N-3, there is an edge from vertex i to vertex i+3, which has weight ci. There are no other edges. For

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