Submission #780848

#TimeUsernameProblemLanguageResultExecution timeMemory
780848borisAngelovPo (COCI21_po)C++17
70 / 70
9 ms1888 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n; int a[maxn]; stack<int> st; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } int ans = 0; for (int i = 1; i <= n; ++i) { while (!st.empty() && st.top() > a[i]) { st.pop(); } if (!st.empty() && st.top() == a[i]) { continue; } if (a[i] != 0) { ++ans; st.push(a[i]); } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...