# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
716450 | immccn123 | Po (COCI21_po) | C++14 | 66 ms | 2192 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |