#5036. 【栈】最小栈

【栈】最小栈

题目描述

维护一个栈,支持基本的入栈、出栈、访问栈顶操作。同时,需要提供一个get_min()方法,该方法需要在O(1)O(1)的时间复杂度下返回栈中最小值。

输入格式

第一行一个整数nn 接下来nn行,每行一种操作,操作分别可能是 push x pop top get_min

输出格式

对于top和get_min操作,输出相应的值 对于非法操作,输出error

样例 #1

样例输入 #1

6
top
push 4
push 5
top
pop
get_min

样例输出 #1

error
5
4

提示

对于20%20\%的数据 0<n<=100<n<=10 另有30%30\%的数据 0<n<=10000<n<=1000 对于100%100\%的数据 0<n<=1000000<n<=100000