제출 #162699

#제출 시각아이디문제언어결과실행 시간메모리
162699Leonardo_PaesBaloni (COCI15_baloni)C++17
100 / 100
85 ms3960 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e6+10;

int h[maxn], mark[maxn];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, ans=0;

    cin >> n;

    for(int i=1; i<=n; i++) cin >> h[i];

    for(int i=n; i>=1; i--){
        if(mark[h[i]-1]){
            mark[h[i]-1]--;
        }
        else{
            ans++;
        }
        mark[h[i]]++;
    }

    cout << ans << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...