← All problemsSign in

Building Permutation

Permutation P is an ordered set of integers P1, P2,  ..., PN, consisting of N distinct positive integers, each of them doesn't exceed N. We'll denote the ith element of permutation P as Pi. We'll call number N the size or the length of permutation P1, P2,  ..., PN. You have a sequence of integers A1, A2,  ..., AN. In one move, you are allowed to decrease or increase any number by one. Count the m

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