K - Max Mod
CodeChefOpen on judge ↗
You have an array $A$ of $N$ integers. Initially all $A_i = 0$. You are also given a **prime** $M$. Handle updates and queries of the following format: 1. Given $X$, $Y$: add $X + (i - 1) \cdot Y$ to $A_i$ for all $1 \le i \le N$. 2. Given $L$, $R$: find the maximum value of $(A_i \bmod M)$ across all $L \le i \le R$. ### Input - The first line of each test contains $3$ integers - $N$, $M$ and
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