#CCBCHBAHAI0000041. Xóa lần xuất hiện cuối cùng của x (Delete the Last Occurrence of x)
Xóa lần xuất hiện cuối cùng của x (Delete the Last Occurrence of x)
Xóa lần xuất hiện cuối cùng của x (Delete the Last Occurrence of x)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer array and an integer .
If there exists an index such that , define
Delete only the element at index and preserve the relative order of all remaining elements.
If does not occur in the array, leave the array unchanged.
Print the logical size after the operation and the resulting array.
Input
The first line contains integers . The second line contains integers .
Output
Print the size after the operation on the first line. If the size is positive, print the resulting array on the second line.
Subtask
Subtask 1 (100 points): ; .
Example
Input
6 3
3 1 3 2 3 4
Output
5
3 1 3 2 4
Explanation
The last occurrence of 3 is at index 4. Only the element at that index is deleted.