Submission #475170

#TimeUsernameProblemLanguageResultExecution timeMemory
475170Ahmed_SolymanPo (COCI21_po)C++14
70 / 70
47 ms1712 KiB
#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 timeMemoryGrader output
Fetching results...