B - Remove It 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 200

問題文

長さ N の整数列 A と整数 X が与えられます。
A から X と等しい要素を全て取り除き、残った要素をそのままの順序で並べた数列 A' を出力してください。

制約

  • 1 \le N \le 10^5
  • 1 \le X \le 10^9
  • 1 \le A_i \le 10^9
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N X
A_1 A_2 A_3 \dots A_N

出力

A' の要素を空白区切りで順に出力せよ。


入力例 1

5 5
3 5 6 5 4

出力例 1

3 6 4

[3, 5, 6, 5, 4] から 5 を取り除くと、[3, 6, 4] になります。


入力例 2

3 3
3 3 3

出力例 2


A' が要素数 0 の数列となる場合があります。この場合、空行を出力するだけで構いません。

Score : 200 points

Problem Statement

Given are an integer sequence A of length N, and an integer X.
Remove all elements that are equal to X from A, and arrange the remaining elements without changing the order to obtain the sequence A'. Print A'.

Constraints

  • 1 \le N \le 10^5
  • 1 \le X \le 10^9
  • 1 \le A_i \le 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X
A_1 A_2 A_3 \dots A_N

Output

Print the elements of A' in order, with space in between.


Sample Input 1

5 5
3 5 6 5 4

Sample Output 1

3 6 4

Removing 5s from [3, 5, 6, 5, 4] results in [3, 6, 4].


Sample Input 2

3 3
3 3 3

Sample Output 2


A' can be a sequence with zero elements, in which case we should just print an empty line.