#include <iostream>
using namespace std;
int n,m,i,j,k,h,z,v[1000010],y[1000010];
short ok[1000010];
int main(){
cin>>n;
for (i=1;i<=n;i++){
cin>>v[i];
y[i]=i;
}
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
if (v[i]<v[j]){
swap(v[i],v[j]);
swap(y[i],y[j]);
}
for (i=1;i<=n;i++)
if (!ok[i]){
k++;
ok[i]=1;
h=v[i]-1;
z=y[i];
for (j=i+1;j<=n && h<=v[j];j++)
if (v[j]==h && y[j]>z && !ok[j]){
ok[j]=1;
h--;
z=y[j];
}
}
cout<<k;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
376 KB |
Output isn't correct |
3 |
Incorrect |
26 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
38 ms |
376 KB |
Output isn't correct |
5 |
Execution timed out |
2072 ms |
10032 KB |
Time limit exceeded |
6 |
Execution timed out |
2051 ms |
10860 KB |
Time limit exceeded |
7 |
Execution timed out |
2037 ms |
8908 KB |
Time limit exceeded |
8 |
Execution timed out |
2079 ms |
8828 KB |
Time limit exceeded |
9 |
Execution timed out |
2008 ms |
9572 KB |
Time limit exceeded |
10 |
Execution timed out |
2072 ms |
9592 KB |
Time limit exceeded |