#include <bits/stdc++.h>
using namespace std;
int N, H[1000005], arrow[1000005], tot = 0;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N;
for (int i = 1; i <= N; ++i){
cin >> H[i];
if (!arrow[H[i]]){
tot++;
arrow[H[i]-1]++;
}
else{
arrow[H[i]]--;
arrow[H[i]-1]++;
}
}
cout << tot << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
78 ms |
7092 KB |
Output is correct |
6 |
Correct |
72 ms |
7416 KB |
Output is correct |
7 |
Correct |
60 ms |
6008 KB |
Output is correct |
8 |
Correct |
62 ms |
6008 KB |
Output is correct |
9 |
Correct |
71 ms |
6520 KB |
Output is correct |
10 |
Correct |
66 ms |
6648 KB |
Output is correct |