Submission #1153891

#TimeUsernameProblemLanguageResultExecution timeMemory
1153891zhehanPo (COCI21_po)C++20
20 / 70
23 ms808 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ int n , x, ans = 1; cin>>n; vector<int> arr(n, 0); stack<int> monostack; for (int i = 0; i < n; ++i){ cin>>arr[i]; } monostack.push(0); for(int i=1;i<n;++i){ while(!monostack.empty() && arr[i]<arr[monostack.top()]){ monostack.pop(); } if(monostack.empty()||arr[i]>arr[monostack.top()]){ ans++; } monostack.push(i); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...