Maximise Sum
You are given an array $A$ consisting of $N$ positive integers. You are allowed to do the following operation any number of times: - Select two integers $l$ and $r$ such that $1 \leq l < r \leq N$; - Change $A_i$ to $\min(A_l, A_r)$ for all $l < i < r$. Find the **maximum** value of $\sum_{i=1}^{N} A_i$ that you can achieve after any (possibly zero) number of operations. ### Input - The first
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