#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int cnt[1000001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, ans = 0;
cin >> n;
while (n--) {
int a;
cin >> a;
if (cnt[a]) cnt[a]--;
else ans++;
cnt[a - 1]++;
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
69 ms |
3940 KB |
Output is correct |
6 |
Correct |
70 ms |
3940 KB |
Output is correct |
7 |
Correct |
56 ms |
3172 KB |
Output is correct |
8 |
Correct |
58 ms |
3172 KB |
Output is correct |
9 |
Correct |
65 ms |
3684 KB |
Output is correct |
10 |
Correct |
62 ms |
3556 KB |
Output is correct |