Earning A Profit
There are $N$ planets numbered $1$ to $N$. You are a space merchant who earns by selling goods on these planets. Traveling to each planet requires you to pay for the fuel. The difficulty of traveling to $i$-th planet is $D_i$. You need to plan your trip by choosing a consecutive sub segment of planets. Your earning of the trip is calculated as follows - - You earn $A$ coins for every planet
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