#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
using namespace std;
int main() {
ll n;
cin>>n;
ll a,x=0;
map<ll,ll> m;
for(int i=0;i<n;i++){
cin>>a;
if(m[a+1]==0) x++;
else m[a+1]--;
m[a]++;
}
cout<<x;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
288 ms |
548 KB |
Output is correct |
6 |
Correct |
292 ms |
488 KB |
Output is correct |
7 |
Correct |
219 ms |
344 KB |
Output is correct |
8 |
Correct |
227 ms |
352 KB |
Output is correct |
9 |
Correct |
256 ms |
384 KB |
Output is correct |
10 |
Correct |
255 ms |
460 KB |
Output is correct |