#C14599. Insert Number into Sorted Array

    ID: 44265 Type: Default 1000ms 256MiB

Insert Number into Sorted Array

Insert Number into Sorted Array

You are given a sorted array of integers and a single integer \(x\). Your task is to insert \(x\) into the array such that the array remains sorted in non-decreasing order.

For example, if the array is \([1, 3, 4, 5]\) and \(x=2\), the resulting array should be \([1, 2, 3, 4, 5]\).

inputFormat

The input is provided via standard input (stdin) and consists of three lines:

  1. The first line contains an integer \(n\), representing the number of elements in the sorted array.
  2. If \(n > 0\), the second line contains \(n\) space-separated integers representing the sorted array.
  3. The third line contains the integer \(x\) to be inserted.

outputFormat

Output the resulting array to standard output (stdout) as a single line of space-separated integers.

## sample
0

3
3