#include <bits/stdc++.h>
#define ll long long
#define MAXH 1000010
using namespace std;
ll cnt[MAXH];
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,h,ans=0;
cin >> n;
for (ll i=1;i<=n;i++)
{
cin >> h;
cnt[h]++;
ans++;
if (cnt[h+1])
{
cnt[h+1]--;
ans--;
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
52 ms |
3900 KB |
Output is correct |
6 |
Correct |
53 ms |
3772 KB |
Output is correct |
7 |
Correct |
41 ms |
3124 KB |
Output is correct |
8 |
Correct |
40 ms |
3124 KB |
Output is correct |
9 |
Correct |
46 ms |
3516 KB |
Output is correct |
10 |
Correct |
49 ms |
3376 KB |
Output is correct |