#include <iostream>
using namespace std;
#define maxn 1000005
int f[maxn];
int main() {
int n; cin >> n;
int ret = 0;
for (int i = 0; i < n; i++) {
int h; cin >> h;
if (f[h+1]) f[h+1]--;
else ret++;
f[h]++;
}
cout << ret << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
216 ms |
3864 KB |
Output is correct |
6 |
Correct |
242 ms |
3732 KB |
Output is correct |
7 |
Correct |
181 ms |
3096 KB |
Output is correct |
8 |
Correct |
178 ms |
3084 KB |
Output is correct |
9 |
Correct |
205 ms |
3472 KB |
Output is correct |
10 |
Correct |
198 ms |
3352 KB |
Output is correct |