#include<bits/stdc++.h>
#define co cout<<
#define ll long long
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
//stuff
void solve(){
ll n;
cin>>n;
ll ans=0,x;
map<ll,ll>mp;
for(int i=0;i<n;i++){
cin>>x;
mp[x-1]++;
if(mp[x]<=0) ans++;
else mp[x]--;
}
co ans;
}
int main(){
suiii
int _=1;
//cin>>_;
while(_--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
157 ms |
756 KB |
Output is correct |
6 |
Correct |
136 ms |
336 KB |
Output is correct |
7 |
Correct |
91 ms |
336 KB |
Output is correct |
8 |
Correct |
92 ms |
760 KB |
Output is correct |
9 |
Correct |
121 ms |
336 KB |
Output is correct |
10 |
Correct |
112 ms |
336 KB |
Output is correct |