← All problemsSign in

Large Differences

CodeChefRating 1294Open on judge ↗

You are given an array $A$ of length $N$, and a positive integer $K$. It is guaranteed that $1 \leq A_i \leq K$ for every index $i$ from $1$ to $N$. You can do the following **at most once**: - Choose an index $i$ ($1 \leq i \leq N$) and a value $x$ ($1 \leq x \leq K$). - Then, set $A_i := x$. Find the **maximum** possible value of the sum of adjacent differences of $A$ after performing this o

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