#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
#include<assert.h>
#include<stack>
void Push(const int value, stack<int>& s1, stack<int>& s2)
{
s1.push(value);
if (s2.size() == 0 || value < s2.top())
{
s2.push(value);
}
else
{
s2.push(s2.top());
}
}
void Pop(stack<int>& s1, stack<int>& s2)
{
assert(s1.size() > 0 && s2.size() > 0);
s1.pop();
s2.pop();
}
int Min(stack<int>& s1, stack<int>& s2)
{
assert(s1.size() > 0 && s2.size() > 0);
return s2.top();
}
void test()
{
stack<int> s1;
stack<int> s2;
Push(3, s1, s2);
Push(4, s1, s2);
Push(2, s1, s2);
Push(1, s1, s2);
cout<<Min(s1, s2)<<endl;
Pop(s1, s2);
cout << Min(s1, s2) << endl;
Pop(s1, s2);
cout << Min(s1, s2) << endl;
Pop(s1, s2);
cout << Min(s1, s2) << endl;
}
int main()
{
test();
return 0;
}