#K50537. Split and Sort Integers

    ID: 28886 Type: Default 1000ms 256MiB

Split and Sort Integers

Split and Sort Integers

Given a list of integers, you are required to split the list into two parts:

  • The first list should contain all the odd numbers in ascending order.
  • The second list should contain all the even numbers in descending order.

For example, if the input list is [4, 1, 7, 5, 6, 2, 3], then the result should be ([1, 3, 5, 7], [6, 4, 2]).

The problem tests your ability to separate and sort numbers based on custom criteria. Note that the even numbers are sorted in descending order while the odd numbers are sorted in ascending order. In mathematical notation, for a number \( x \):

  • \( x \) is odd if \( x \bmod 2 \neq 0 \).
  • \( x \) is even if \( x \bmod 2 = 0 \).

inputFormat

The first line contains an integer n, the number of integers in the list. The second line contains n space-separated integers.

outputFormat

The output should consist of two lines:

  • The first line contains the sorted odd numbers (in ascending order), separated by spaces.
  • The second line contains the sorted even numbers (in descending order), separated by spaces.

If there are no odd or no even numbers, output an empty line for that part.

## sample
7
4 1 7 5 6 2 3
1 3 5 7

6 4 2

</p>