#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
87 ms |
4692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
3672 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |