题解 | 小红的数组清空
小红的数组清空
https://www.nowcoder.com/practice/c0784de498ca4779b3dc2a75fddcf12b
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
map<int,int>m;
for(int i=0;i<n;i++){
int v;
cin>>v;
m[v]++;
}
int ans=0;
for(auto [x,y]:m){
int now=m[x],la=m[x-1];
ans+=max(now-la,0);
}
cout<<ans<<endl;
}