← All problemsSign in

Sereja and Progressions

CodeChefRating 3682Open on judge ↗

Sereja likes arithmetic progressions a lot. An infinite arithmetic progression (a, r) is determined by its initial term and difference of consecutive terms, denoted by a, r respectively. He defines mutual attraction of some array A of size N with an infinite arithmetic progression (a, r), as |A1 - a| + |A2 - (a + r)| + .. + |Ai - (a + r * (i - 1)| + .. + |AN - (a + r * (N - 1)|, where |x| denote

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