class Solution {
public:
stack<int> temp,temp1;
//压入时,temp按照单调栈进行,确保最小值再栈顶
void push(int value) {
temp.push(value);
if(temp1.empty())
{
temp1.push(value);
}
else
{
vector<int> v;
while(!temp1.empty()&&temp1.top()<value)
{
v.push_back(temp1.top());
temp1.pop();
}
temp1.push(value);
for(int i=v.size()-1;i>=0;i--)
{
temp1.push(v[i]);
}</int></int>

    }
}
//弹出时保证单调栈中的数值相应第被弹出。
void pop() {
    int d=temp.top();
    vector<int> s;
    while(temp1.top()!=d)
    {
        s.push_back(temp1.top());
        temp1.pop();
    }
    temp1.pop();
    for(int i=s.size()-1;i>=0;i--)
    {
        temp1.push(s[i]);
    }
    temp.pop();
}
int top() {
   return temp.top();
}
int min() {
    return temp1.top();
}

};