#CCBCHBAHAI0000075. Chèn x trước lần xuất hiện cuối cùng của y (Insert x Before the Last Occurrence of y)
Chèn x trước lần xuất hiện cuối cùng của y (Insert x Before the Last Occurrence of y)
Insert x Before the Last Occurrence of y
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
A static array has capacity and current logical size :
Given integers and , define
If and , let and insert immediately before . The new array has size and
$$b_i=\begin{cases} a_i,&0\le i<p,\\x,&i=p,\\a_{i-1},&p<i\le n.\end{cases}$$If or , leave the array unchanged. Print the final logical size and array.
Input
The first line contains and . The second line contains . The third line contains and .
Output
Print the final logical size on the first line and the active array elements on the second line.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
8 6
4 2 7 2 9 5
100 2
Output
7
4 2 7 100 2 9 5
Explanation
The output follows directly from the mathematical definition above.