Maximum Smaller
You are given an array $A$ of size $N$. The score of a permutation $P$ of the integers $[1, N]$ is defined as follows: - If $P_i = i$ for at least one $i$ ($1 \le i \le N$), the score is $-1$. - Otherwise, the score is the number of indices $i$ ($1 \le i \le N$) such that $A_{P_i} \le A_i$. Find the maximum possible score for some permutation $P$. You also need to print a valid permutation. ##
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