#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int a[n];
multiset<int> st;
int cnt=0;
for(int i=0;i<n;i++){
cin>>a[i];
if(st.find(a[i]+1)!=st.end())st.erase(st.find(a[i]+1));
else cnt++;
st.insert(a[i]);
}
cout<<cnt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
169 ms |
6480 KB |
Output is correct |
6 |
Correct |
210 ms |
7524 KB |
Output is correct |
7 |
Correct |
174 ms |
6392 KB |
Output is correct |
8 |
Correct |
171 ms |
6224 KB |
Output is correct |
9 |
Correct |
172 ms |
6480 KB |
Output is correct |
10 |
Correct |
178 ms |
6736 KB |
Output is correct |