#include <bits/stdc++.h>
using namespace std;
const int N = 1000*1000+5;
int a[N];
bool col[N];
int main(){
ios_base::sync_with_stdio(false);
int n;
cin>>n;
for(int i = 1;i<=n;i++) cin>>a[i];
int ans = 0;
for(int i = 1;i<=n;i++){
if(col[i]) continue;
ans++;
int now = a[i];
now--;
for(int j = i+1;j<=n;j++){
if(col[j]) continue;
if(a[j] == now){
col[j] = 1;
now--;
}
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
376 KB |
Output is correct |
3 |
Correct |
23 ms |
376 KB |
Output is correct |
4 |
Correct |
32 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
2041 ms |
4316 KB |
Time limit exceeded |
6 |
Execution timed out |
2041 ms |
4856 KB |
Time limit exceeded |
7 |
Execution timed out |
2058 ms |
4088 KB |
Time limit exceeded |
8 |
Execution timed out |
2069 ms |
3960 KB |
Time limit exceeded |
9 |
Execution timed out |
2053 ms |
4256 KB |
Time limit exceeded |
10 |
Execution timed out |
2049 ms |
4316 KB |
Time limit exceeded |