#include <bits/stdc++.h>
using namespace std;
const int nx=1e6+5;
int n, x, dp[nx], ans;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>x;
if (dp[x+1]) dp[x+1]--, dp[x]++;
else dp[x]++, ans++;
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
42 ms |
4040 KB |
Output is correct |
6 |
Correct |
47 ms |
3760 KB |
Output is correct |
7 |
Correct |
38 ms |
3152 KB |
Output is correct |
8 |
Correct |
34 ms |
3172 KB |
Output is correct |
9 |
Correct |
39 ms |
3648 KB |
Output is correct |
10 |
Correct |
40 ms |
3408 KB |
Output is correct |