Lazy Machine
CodeChefOpen on judge ↗
You're given an array $A$ with $N$ integers. Define $F(A, i, j) = (A[j]-A[i]) \cdot (j-i)$. Consider the set $P$ of all pairs $(i, j)$ such that $1 \leq i \lt j \leq N$. For a subset $S$ of $P$, we define $\texttt{beauty}(S, A)$ as the sum of $F(A, i, j)$ over all pairs $(i, j)$ contained in $S$. We also define $V(A)$ as the maximum value of $\texttt{beauty}(S, A)$ over all subsets $S$ of $P$.
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