网址: https://cspjs.online/contest/660/problem/2
题解: https://b1bznc26af6.feishu.cn/file/EGvfbzAGno8mvYxG0JJcLcIgn9d?from=from_copylink
#include <bits/stdc++.h>
using namespace std;
long long minn = -1;
int num[10100];
int main() {
freopen("game.in", "r", stdin);
freopen("game.out", "w", stdout);
std::ios::sync_with_stdio(false);
int n, ans = 0, cnt = 1;
cin >> n;
memset(num, -1, sizeof(num));
for (int i = 0; i < n; i++) {
cin >> num[i];
}
sort(num, num + n);
for (int i = 0; i < n; i++) {
int a = num[i];
if (num[i] != -1) {
for (int j = 0; j < n; j++) {
if (num[j] == a + 1) {
a = num[j];
num[j] = -1;
cnt++;
}
}
if (cnt >= 2) {
ans++;
cnt = 1;
num[i] = -1;
}
}
}
cout << ans;
return 0;
}