#include <bits/stdc++.h>
using namespace std;
int n,co;
int v[100000000];
bool take[100000000];
int main()
{
cin>>n;
//v.resize(n);
for (int i=0;i<n;i++)
cin>>v[i];
for (int i=0;i<n;i++)
{int c=1;
for (int z=i;z>=0;z--)
{
if (v[z]==v[i]+1&&take[z]==0)
{c=0;
take[z]=1;
break;}
}
co+=c;
}
cout <<co;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
6 ms |
364 KB |
Output is correct |
4 |
Correct |
8 ms |
364 KB |
Output is correct |
5 |
Correct |
1206 ms |
4616 KB |
Output is correct |
6 |
Execution timed out |
2084 ms |
4916 KB |
Time limit exceeded |
7 |
Execution timed out |
2083 ms |
4504 KB |
Time limit exceeded |
8 |
Execution timed out |
2053 ms |
4076 KB |
Time limit exceeded |
9 |
Correct |
1760 ms |
4460 KB |
Output is correct |
10 |
Execution timed out |
2098 ms |
4460 KB |
Time limit exceeded |