← All problemsSign in

Final Sum

CodeChefRating 1145Open on judge ↗

Chef has an array $A$ of length $N$. In one operation, Chef can: - Choose any subarray $[L, R]$ $(1 \leq L \leq R \leq N)$; - Add $1$ to $A_L$, subtract $1$ from $A_{L+1}$, add $1$ to $A_{L+2}$, subtract $1$ from $A_{L+3}$ and so on, till $A_R$. Chef performed $Q$ such operations where the $i^{th}$ operation was performed on the subarray $[L_i, R_i]$. Determine the final **sum** of the array af

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