Submission #372996

#TimeUsernameProblemLanguageResultExecution timeMemory
372996sam571128Po (COCI21_po)C++14
70 / 70
15 ms1536 KiB
#include <bits/stdc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; signed main(){ fastio int n; cin >> n; int arr[n]; stack<int> s; int ans = 0; for(auto &x : arr){ cin >> x; while(!s.empty()&&s.top()>x){ s.pop(); } if(x==0) continue; if(s.empty()||s.top()!=x){ ans++; s.push(x); } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...