Source Code
#include <bits/stdc++.h>
using namespace std;
const int N= 3e5;
map<int, int>mp; 
int main() {
	// your code goes here
	int n, m;
	cin>>n>>m;
	for (int i = 0; i<n; ++i) {
		int x; 
		cin>>x;
		mp[x]++;
	}
	if (m == 0) {
		cout<<mp[0]<<endl;
		return 0; 
	}
	if (mp[m] == 0)
		puts("0");
	else if (mp[m] % 2 == 0)
		cout<<mp[m]-1<<endl;
	else 
		cout<<mp[m]<<endl;
	return 0;
}
Copy
Legendary Chicou
GNU G++17
224 ms
10.3 MB
Accepted