#CCBCHBAHAI0000037. Chèn x tại vị trí p (Insert x at Position p)
Chèn x tại vị trí p (Insert x at Position p)
Chèn x tại vị trí p (Insert x at Position p)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
A static array has capacity and current logical size , where
The current array is . Given an insertion index and value , where
Insert at index . The new size is . The result satisfies
and
Print the new size and the resulting array.
Input
The first line contains integers . If , the second line contains integers .
Output
Print on the first line. Print the array after insertion on the second line.
Subtask
Subtask 1 (100 points): ; ; ; .
Example
Input
6 4 2 99
10 20 30 40
Output
5
10 20 99 30 40
Explanation
The old elements from index 2 onward shift one position to the right, then is stored at index 2.