제출 #1116447

#제출 시각아이디문제언어결과실행 시간메모리
1116447heeyBaloni (COCI15_baloni)C++14
100 / 100
1523 ms12180 KiB
#include<bits/stdc++.h>
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];



    vector<stack<int>> ss(1);
    for(int i = 0; i < n; i++){
        int j = 0;
        while(!ss[j].empty() && ss[j].top() != h[i] + 1) j++;
        if(ss[j].empty()) {
            ss.push_back(stack<int>());
        }
        ss[j].push(h[i]);
    }

    cout << ss.size() - 1<< '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...