Submission #1153899

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