#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i = 0;i<n;i++)cin>>arr[i];
map<int,int> mp;
int ans = 0;
for(int i = 0;i<n;i++){
if(mp[arr[i]]){
mp[arr[i]]--;
mp[arr[i]-1]++;
}else{
mp[arr[i]-1]++;
ans++;
}
}
cout<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
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 |
330 ms |
7196 KB |
Output is correct |
6 |
Correct |
342 ms |
7320 KB |
Output is correct |
7 |
Correct |
250 ms |
6032 KB |
Output is correct |
8 |
Correct |
278 ms |
5920 KB |
Output is correct |
9 |
Correct |
292 ms |
6664 KB |
Output is correct |
10 |
Correct |
329 ms |
6568 KB |
Output is correct |