#include<bits/stdc++.h>
using namespace std;
#define int64_t long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
void Solve(void) {
int N; cin >> N;
vector<int> h(1000005);
int ans = 0;
for (int i = 1; i <= N; i ++) {
int x; cin >> x;
if (h[x] == 0) {
ans ++;
h[x - 1] ++;
} else {
h[x] --;
h[x - 1] ++;
}
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int Tests = 1; // cin >> Tests;
while (Tests --) {
Solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4184 KB |
Output is correct |
2 |
Correct |
2 ms |
4184 KB |
Output is correct |
3 |
Correct |
1 ms |
4188 KB |
Output is correct |
4 |
Correct |
1 ms |
4184 KB |
Output is correct |
5 |
Correct |
41 ms |
7888 KB |
Output is correct |
6 |
Correct |
39 ms |
7764 KB |
Output is correct |
7 |
Correct |
30 ms |
7176 KB |
Output is correct |
8 |
Correct |
30 ms |
7000 KB |
Output is correct |
9 |
Correct |
35 ms |
7508 KB |
Output is correct |
10 |
Correct |
34 ms |
7504 KB |
Output is correct |