#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int say=0;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int x=0;x<n;x++){
int mx=a[x];
if(mx==-1)continue;
else say++;
int i=0;
for(i=x+i;i<n;i++){
if(mx-1==a[i]){
a[i]=-1;
mx--;
}
}}
cout<<say;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
5 ms |
508 KB |
Output is correct |
4 |
Correct |
8 ms |
336 KB |
Output is correct |
5 |
Correct |
1073 ms |
3408 KB |
Output is correct |
6 |
Execution timed out |
2063 ms |
3664 KB |
Time limit exceeded |
7 |
Execution timed out |
2064 ms |
3152 KB |
Time limit exceeded |
8 |
Execution timed out |
2045 ms |
3152 KB |
Time limit exceeded |
9 |
Correct |
1646 ms |
3408 KB |
Output is correct |
10 |
Execution timed out |
2044 ms |
3512 KB |
Time limit exceeded |