Is this constructive permutations problem solvable?

Revision en1, by Phantom_Dreams, 2025-03-19 08:29:02

I came up with the following problem:

Given an array $$$A$$$ of $$$N$$$ non-negative integers, output $$$2$$$ permutations $$$X$$$ and $$$Y$$$ such that $$$|X_i - Y_i| \le A_i$$$ for all $$$(1 \le i \le N)$$$ or report that it is impossible to do so.

For example, given this test case:
$$$N = 5$$$
$$$A = [2,2,4,2,2]$$$

The output could be:
$$$X = [5,2,1,3,4]$$$
$$$Y = [3,4,5,1,2]$$$

I have not given constraints on $$$N$$$ as I am not sure what the best possible time complexity of a solution to this problem is.

Tags constructive, permutations

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Phantom_Dreams 2025-03-19 08:31:28 4
en2 English Phantom_Dreams 2025-03-19 08:31:05 2 Tiny change: '(1 \le i \le N)$ or r' -> '(1 \le i \ge N)$ or r'
en1 English Phantom_Dreams 2025-03-19 08:29:02 556 Initial revision (published)