# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780848 | borisAngelov | Po (COCI21_po) | C++17 | 9 ms | 1888 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |