#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=0;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 |
5 ms |
364 KB |
Output is correct |
3 |
Correct |
14 ms |
376 KB |
Output is correct |
4 |
Correct |
20 ms |
364 KB |
Output is correct |
5 |
Execution timed out |
2098 ms |
3564 KB |
Time limit exceeded |
6 |
Execution timed out |
2094 ms |
3948 KB |
Time limit exceeded |
7 |
Execution timed out |
2064 ms |
3308 KB |
Time limit exceeded |
8 |
Execution timed out |
2060 ms |
3308 KB |
Time limit exceeded |
9 |
Execution timed out |
2066 ms |
3436 KB |
Time limit exceeded |
10 |
Execution timed out |
2059 ms |
3564 KB |
Time limit exceeded |