class stack
{
public:
stack(int size=100)
{
buff=new int[size];
cur=-1;
}
~stack()
{
delete[] buff;
}
void push(int val)
{
buff[++cur]=val;
}
void pop()
{
--cur;
}
int top()
{
return buff[cur];
}
bool empty()
{
return cur==-1;
}
private:
int* buff;
int cur;
}
class stackwithmin
{
public:
stackwithmin()
{
}
~stackwithmin()
{}
void push(int val)
{
s1.push(val);
if(val<=min())
s2.push(val);
}
void pop()
{
if(s1.top()==min())
s2.pop();
s1.pop();
}
int top()
{
return s1.top();
}
bool empty()
{
return s1.empty();
}
int min()
{
if(s2.empty())
return INT_MAX;
else return s2.top();
}
private:
stack s1,s2;
}
{
public:
stack(int size=100)
{
buff=new int[size];
cur=-1;
}
~stack()
{
delete[] buff;
}
void push(int val)
{
buff[++cur]=val;
}
void pop()
{
--cur;
}
int top()
{
return buff[cur];
}
bool empty()
{
return cur==-1;
}
private:
int* buff;
int cur;
}
class stackwithmin
{
public:
stackwithmin()
{
}
~stackwithmin()
{}
void push(int val)
{
s1.push(val);
if(val<=min())
s2.push(val);
}
void pop()
{
if(s1.top()==min())
s2.pop();
s1.pop();
}
int top()
{
return s1.top();
}
bool empty()
{
return s1.empty();
}
int min()
{
if(s2.empty())
return INT_MAX;
else return s2.top();
}
private:
stack s1,s2;
}