#include <bits/stdc++.h>
using namespace std;
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define NACHO ios_base::sync_with_stdio(0);cin.tie(NULL);
typedef long long tint;
int main(){
int n; cin >> n;
vector<int> a (n);
forn(i, n) cin >> a[i];
vector<int> visited (1000002, 0);
vector<bool> tiene (n, 0);
forn(i, n){
visited[a[i]]++;
if(visited[a[i]+1]){ tiene[i] = 1; visited[a[i]+1]--;}
}
int cont = 0;
forn(i, n){
if(tiene[i] == 0) cont++;
}
cout << cont << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
3 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
209 ms |
7524 KB |
Output is correct |
6 |
Correct |
218 ms |
8036 KB |
Output is correct |
7 |
Correct |
178 ms |
7140 KB |
Output is correct |
8 |
Correct |
171 ms |
7140 KB |
Output is correct |
9 |
Correct |
194 ms |
7396 KB |
Output is correct |
10 |
Correct |
192 ms |
7396 KB |
Output is correct |