-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1203E.cpp
More file actions
46 lines (44 loc) · 759 Bytes
/
1203E.cpp
File metadata and controls
46 lines (44 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
ll n;
cin >> n;
ll a[n];
for(int i = 0 ;i < n ; i++)
cin >> a[i];
sort(a , a+ n);
int count = 0;
for(int i = 0 ; i < n ; i++)
{
if( i == 0 && a[i] != 1)
{
a[i]--;
}
else if( i != 0)
{
if(a[i] == a[i - 1])
{
a[i] ++;
}
else if(a[i] > a[i - 1] + 1)
{
a[i] --;
}
else if(a[i] < a[i - 1])
a[i] = a[i - 1];
}
}
ll c[150002] = {0};
for(int i = 0; i < n ; i++)
{
if(c[a[i]] == 0)
{
count ++;
c[a[i]] = 1;
}
}
cout << count << endl;
}