Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T> class stupid_stack {
- std::stack<T> stuff;
- std::stack<T> max;
- public:
- void push(const T& t) {
- stuff.push(t);
- max.push(std::max(t, max.top()));
- }
- void pop() {
- stuff.pop();
- max.pop();
- }
- T max() {
- return max.top();
- }
- T top() {
- return stuff.top();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment