#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int n, arr[N];
vector<vector<int>> pos(N);
int main(){
cin.tie(0); ios::sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; ++i) cin >> arr[i];
int ans = 0;
for(int i = 0; i < n; ++i){
if(pos[arr[i] + 1].empty()){
++ans;
}else pos[arr[i] + 1].pop_back();
pos[arr[i]].push_back(i);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23756 KB |
Output is correct |
2 |
Correct |
13 ms |
23756 KB |
Output is correct |
3 |
Correct |
13 ms |
23808 KB |
Output is correct |
4 |
Correct |
14 ms |
23800 KB |
Output is correct |
5 |
Correct |
71 ms |
26908 KB |
Output is correct |
6 |
Correct |
94 ms |
27360 KB |
Output is correct |
7 |
Correct |
85 ms |
26716 KB |
Output is correct |
8 |
Correct |
60 ms |
26636 KB |
Output is correct |
9 |
Correct |
67 ms |
26796 KB |
Output is correct |
10 |
Correct |
65 ms |
26924 KB |
Output is correct |