#include <iostream>
using namespace std;
long long n,i,s=1,x,x1,v[1000001];
long long v1[1000001];
int main()
{
cin>>n;
for(i=1; i<=n; i++)
{
cin>>v[i];
}
for(i=2; i<=n; i++)
{
if(v[i]!=v[i-1]-1)
{
if(v1[v[i]]>0)
{
v1[v[i]]--;
v1[v[i]-1]++;
}
if(v1[v[i]]==0)
{
s++;
v1[v[i-1]-1]++;
}
}
}
cout<<s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
5 |
Incorrect |
167 ms |
6444 KB |
Output isn't correct |
6 |
Incorrect |
182 ms |
7200 KB |
Output isn't correct |
7 |
Incorrect |
141 ms |
6040 KB |
Output isn't correct |
8 |
Incorrect |
141 ms |
5840 KB |
Output isn't correct |
9 |
Incorrect |
149 ms |
6208 KB |
Output isn't correct |
10 |
Incorrect |
153 ms |
6400 KB |
Output isn't correct |