Submission #716450

#TimeUsernameProblemLanguageResultExecution timeMemory
716450immccn123Po (COCI21_po)C++14
70 / 70
66 ms2192 KiB
#include <iostream> #include <stack> #define ll long long using namespace std; ll a[100001], n, ans = 0; stack<int> s; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { while (!s.empty() && s.top() > a[i]) s.pop(); if (!s.empty() && s.top() == a[i]) continue; if (a[i]) s.push(a[i]), ans++; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...