Official

B - Remove It Editorial by en_translator


You can obtain the correct answer by implementing the problem statement.
Alternatively you can output while skipping the elements that is equal to \(X\).

Sample Code (C++)

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int x = ri();
	int a[n];
	for (auto &i : a) i = ri();
	
	bool beginning = true;
	for (int i = 0; i < n; i++) {
		if (a[i] == x) continue;
		if (beginning) beginning = false;
		else printf(" ");
		printf("%d", a[i]);
	}
	puts("");
	return 0;
}

Sample Code (Python)

n, x = map(int, input().split())
a = list(map(int, input().split()))
print(" ".join([str(i) for i in a if i != x]))

posted:
last update: