You are given an integer array of length and integer . Your should divide this array onto two arrays and with such rules:
Your task is to maximize the following value: , where is equal to if and otherwise.
Input format:
First line contains two space-separated integers and .
Next line contains space-separated integers denoting the array .
Output format:
In a first line output space-separated integers denoting array .
In a second line output space-separated integers denoting array .
Verdict and scoring:
Your score is equal to the sum of the values of all test cases.
The value of each test is calculated using this formula: , where is equal to if and otherwise.
If at least one of the rules will be violated, then your value for this test will be .
Test generation plan:
Each test has own upper bound (), denoting that every in this test is not exceeding .
In each test and are randomly generated (considering constraints), is not randomly generated.
In 38% tests: all elements of array are randomly generated (considering constraints and limit ).
In all other tests: while the current amount of written elements is not equal to do:
Elements of array corresponding to indices of array : .
Elements of array corresponding to indices of array : .
In this case the score is equal to .