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;
long long n,v[300010];
stack<int>s;
int main()
{
cin>>n;
for(int i=1;i<=n;++i)
cin>>v[i];
for(int i=1;i<=n;++i)
cout<<1<<'\n';
for(int i=n;i>=0;--i)
{
if(s.empty()&&v[i]>=0)
{
cout<<v[i];
return 0;
}
if(v[i]>=0)
v[i]=0;
if(!s.empty()&&v[i]>s.top())
s.pop();
else
s.push(v[i]);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |