class achievestack
{
public:
void push(int value)
{
if (s1.empty() && s2.empty())
{
s1.push(value);
s2.push(value);
}
else
{
if (value <= s2.top())
{
s2.push(value);
}
s1.push(value);
}
}
void pop()
{
if (s2.top() == s1.top())
{
s2.pop();
}
s1.pop();
}
int min()
{
return s2.top();
}
protected:
stack<int> s1;
stack<int> s2;
};
int main()
{
achievestack s;
s.push(3);
s.push(4);
s.push(5);
s.push(16);
s.push(1);
s.push(1);
s.push(2);
cout << s.min() << endl;
s.pop();
s.pop();
cout << s.min() << endl;
}