제출 #132776

#제출 시각아이디문제언어결과실행 시간메모리
132776VardanyanBaloni (COCI15_baloni)C++14
40 / 100
2069 ms4856 KiB
#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 timeMemoryGrader output
Fetching results...