Construct Permutation
You are given integers $N$ and $K$. Find a permutation $P$ of length $N$ such that: - $\sum_{i=1}^{N} ( \max\limits_{j = 1}^{i} P_j - \min\limits_{j = 1}^{i} P_j ) = K$ If there exists multiple $P$, you can print any one. Otherwise report that it is not possible. Note that a permutation of length $N$ consists of all integers from $1$ to $N$ exactly once. ### Input - The first line contains a
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