#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
unordered_map<int,int>mp;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,cnt=0;
cin>>n;
int h[n];
for(int i=0;i<n;i++)cin>>h[i];
for(int i=0;i<n;i++){
mp[h[i]]++;
if(mp[h[i]+1]==0)cnt++;
else mp[h[i]+1]--;
}
cout<<cnt<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
47 ms |
7260 KB |
Output is correct |
6 |
Correct |
51 ms |
7504 KB |
Output is correct |
7 |
Correct |
38 ms |
5968 KB |
Output is correct |
8 |
Correct |
52 ms |
6324 KB |
Output is correct |
9 |
Correct |
43 ms |
6480 KB |
Output is correct |
10 |
Correct |
42 ms |
6740 KB |
Output is correct |