#include <iostream>
#include <cstdio>
using namespace std;
const string TASK = "Baloni";
int n,h[(int)1e6+1],c[(int)1e6+1],res;
void Enter()
{
cin >> n;
for (int i=1;i<=n;++i)
cin >> h[i];
}
void Init()
{
}
void Solve()
{
res = 0;
for (int i=1;i<=n;++i)
if (c[h[i]] == 0) {
++res;
++c[h[i]-1];
}
else {
--c[h[i]];
++c[h[i]-1];
}
cout << res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen((TASK+".INP").c_str(),"r",stdin);
//freopen((TASK+".OUT").c_str(),"w",stdout);
Enter();
Init();
Solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
69 ms |
9988 KB |
Output is correct |
6 |
Correct |
73 ms |
9988 KB |
Output is correct |
7 |
Correct |
49 ms |
9988 KB |
Output is correct |
8 |
Correct |
59 ms |
9988 KB |
Output is correct |
9 |
Correct |
73 ms |
9988 KB |
Output is correct |
10 |
Correct |
73 ms |
9988 KB |
Output is correct |