← All problemsSign in

Sereja and Permutations

CodeChefRating 2805Open on judge ↗

Sereja has an array A of N integers: A[1], A[2], …, A[N]. Sereja also has an integer D. Sereja calls a permutation P[1], P[2], …, P[N] as good if the following conditions hold. A[P[1]] + D > A[P[2]], A[P[2]] + D > A[P[3]], ⋮ A[P[N-1]] + D > A[P[N]]. Sereja wants to sequentially perform M single-element replacement operations on the array. Each of these operations consists of choosing an i

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