Codeforces #713(Div.3) E: Permutation by Sum
Problem Overview Consider the permutation 1 to \(n\) called \(P\). The parameters \(l, r, s\) that satisfies \(1 \leq l \leq r \leq n\) and \(1 \leq s \leq \frac{n(n + 1)}{2}\) are given. Find the permutation which satisfies \(P_{l} + P_{l + 1} + … + P_{r} = s\). Print any permutation of length \(n\) that fits the condition above if such a permutation exists; otherwise, -1. Problem Explanation First, consider the minimum and the maximum value we can generate with the length \(r - l + 1\).