题目链接:http://codeforces.com/contest/1203/problem/E
思路:能减1就减,不然本身,再不然就加1,还不行就...........
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int A[150010];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&A[i]);
sort(A,A+n);
int ans=0;
for(int i=0;i<n;i++)
{
if(mp.count(A[i]-1)==0&&A[i]!=1)
{
ans++;
mp[A[i]-1]=1;
}
else if(mp.count(A[i])==0)
{
ans++;
mp[A[i]]=1;
}
else if(mp.count(A[i]+1)==0)
{
ans++;
mp[A[i]+1]=1;
}
}
printf("%d\n",ans);
}