#CCBCHBAHAI0000077. Xóa mọi phần tử ngoài đoạn [L, R] (Remove Elements Outside [L, R])
Xóa mọi phần tử ngoài đoạn [L, R] (Remove Elements Outside [L, R])
Remove Elements Outside [L, R]
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given and integers , keep exactly the elements satisfying
remove all others, and preserve the relative order of the kept elements. If is the set of kept indices, then .
Input
The first line contains , , and . The second line contains integers .
Output
Print , then the filtered array on the second line; if , the second line is empty.
Subtask
Subtask 1 (20 points): , , .
Subtask 2 (30 points): , , .
Subtask 3 (50 points): , , .
Example
Input
7 -2 5
-7 -2 0 8 5 6 1
Output
4
-2 0 5 1
Explanation
The output follows directly from the mathematical definition above.