답안 #1116447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116447 2024-11-21T16:30:37 Z heey Baloni (COCI15_baloni) C++14
100 / 100
1523 ms 12180 KB
#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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1104 KB Output is correct
2 Correct 3 ms 1616 KB Output is correct
3 Correct 6 ms 1872 KB Output is correct
4 Correct 8 ms 1952 KB Output is correct
5 Correct 728 ms 10704 KB Output is correct
6 Correct 1523 ms 12180 KB Output is correct
7 Correct 1258 ms 10312 KB Output is correct
8 Correct 1152 ms 10236 KB Output is correct
9 Correct 995 ms 10568 KB Output is correct
10 Correct 1263 ms 11140 KB Output is correct