← All problemsSign in

Yet another subarray problem

CodeChefRating 1478Open on judge ↗

Given a positive integer $N$, find an array $A = [A_1, A_2, \ldots, A_N]$ of length $N$ consisting of **distinct** integers from $1$ to $10^9$, such that the following condition is satisfied for each subarray $[A_L, A_{L+1}, \ldots, A_r]$ ($1\leq L \leq R\leq N$): - The sum of elements in the subarray is divisible by its length i.e. $A_L + A_{L+1} + \ldots + A_R$ is divisible by $R - L + 1$. It

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