#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
int a[N];
bool vis[N];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int p=0;
map<int,int>mp;
for(int i=1;i<=n;i++){
if(mp[a[i]+1]==0){
p++;
mp[a[i]]++;
}
else{
mp[a[i]+1]--;
mp[a[i]]++;
}
}
cout<<p;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2404 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Runtime error |
51 ms |
5456 KB |
Execution killed with signal 11 |
6 |
Runtime error |
47 ms |
5296 KB |
Execution killed with signal 11 |
7 |
Runtime error |
46 ms |
5460 KB |
Execution killed with signal 11 |
8 |
Runtime error |
44 ms |
5468 KB |
Execution killed with signal 11 |
9 |
Runtime error |
53 ms |
5300 KB |
Execution killed with signal 11 |
10 |
Runtime error |
46 ms |
5456 KB |
Execution killed with signal 11 |