Submission #475170

# Submission time Handle Problem Language Result Execution time Memory
475170 2021-09-21T10:28:13 Z Ahmed_Solyman Po (COCI21_po) C++14
70 / 70
47 ms 1712 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll n;cin>>n;
    vector<ll>arr(n);
    for(auto &i:arr)cin>>i;
    vector<ll>v;
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(arr[i]==0){
            v.push_back(0);
            continue;
        }
        while(v.size() && v[v.size()-1]>arr[i]){
            v.pop_back();
        }
        if(!v.size())ans++;
        else if(v[v.size()-1]<arr[i])ans++;
        v.push_back(arr[i]);
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 11 ms 820 KB Output is correct
5 Correct 16 ms 1020 KB Output is correct
6 Correct 47 ms 1712 KB Output is correct
7 Correct 46 ms 1080 KB Output is correct