Submission #1137353

#TimeUsernameProblemLanguageResultExecution timeMemory
1137353rixiepixiePo (COCI21_po)C++20
70 / 70
6 ms1608 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ///
    int n;
    cin >> n;

    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    stack<ll> st;
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        while (!st.empty() && st.top() > a[i]) {
            st.pop();
        }
        if (a[i] > 0 && (st.empty() || st.top() < a[i])) {
            ans++;
            st.push(a[i]);
        }
    }
    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...