← All problemsSign in

Chotu and Gang

There are n cities in a country and there exist road between every two cities. Each city i (1<=i <= n) has its money status shown as a[i] ie if(a[i]>0) The city i is in a profit of a[i] value. if(a[city]<0) The city i is in a loss of a[i] value. All cities are very friendly to each other, so they decided to share their money in a way such that no city remains in loss. Money will be

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