#include <fstream>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<bool>p(n,false);
int x=0;
vector<int>a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
int y;
for(int i=0;i<n;i++){
if(p[i])continue;
x++;
p[i]=true;
y=a[i]-1;
for(int j=i+1;j<n;j++){
if(!p[j]&&a[j]==y){
p[j]=true;
y--;
if(y==0)break;
}
}
}
cout<<x;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
11 ms |
364 KB |
Output is correct |
4 |
Correct |
16 ms |
364 KB |
Output is correct |
5 |
Execution timed out |
2055 ms |
3564 KB |
Time limit exceeded |
6 |
Execution timed out |
2097 ms |
3948 KB |
Time limit exceeded |
7 |
Execution timed out |
2083 ms |
3308 KB |
Time limit exceeded |
8 |
Execution timed out |
2075 ms |
3308 KB |
Time limit exceeded |
9 |
Execution timed out |
2062 ms |
3436 KB |
Time limit exceeded |
10 |
Execution timed out |
2090 ms |
3564 KB |
Time limit exceeded |