Minimum Operations
Suppose you have an array $B \ (0 \leq B_i \leq 10^9)$ of length $M$, and a positive integer $K \ (1 \leq K \lt M)$. You are allowed to do the following operation on $B$: - Select $x$ indices $i_1, i_2, \ldots, i_x \ (1 \leq i_j \leq M)$, such that $(i_{j + 1} - i_j) \geq K$ for all $1 \leq j \lt x$; - Subtract $1$ to $B_{i_j}$ for all $1 \leq j \leq x$. For the array $B$ and integer $K$, let
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