#C14599. Insert Number into Sorted Array
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:
- The first line contains an integer \(n\), representing the number of elements in the sorted array.
- If \(n > 0\), the second line contains \(n\) space-separated integers representing the sorted array.
- 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.
## sample0
3
3