#include <bits/stdc++.h>
using namespace std;
int a[1000100];
int n;
int v[1001000];
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
// int mx=0;
int h=0; int ans=0;
while(h<n)
{
int mx=0;
for(int i=0;i<n;i++)
{
if(v[i]) continue;
mx=max(mx,a[i]);
}
int s=mx;
for(int i=0;i<n;i++)
{
if(v[i]) continue;
if(a[i]==s)
{
h++;
s--;
v[i]=1;
}
}
ans++;
//for(int i=0;i<n;i++)
// cout<<v[i]<<" ";
// cout<<endl;
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
204 KB |
Output is correct |
2 |
Correct |
14 ms |
328 KB |
Output is correct |
3 |
Correct |
52 ms |
332 KB |
Output is correct |
4 |
Correct |
67 ms |
332 KB |
Output is correct |
5 |
Execution timed out |
2076 ms |
9956 KB |
Time limit exceeded |
6 |
Execution timed out |
2066 ms |
10672 KB |
Time limit exceeded |
7 |
Execution timed out |
2078 ms |
8832 KB |
Time limit exceeded |
8 |
Execution timed out |
2068 ms |
8644 KB |
Time limit exceeded |
9 |
Execution timed out |
2083 ms |
9452 KB |
Time limit exceeded |
10 |
Execution timed out |
2099 ms |
9540 KB |
Time limit exceeded |