1.题目要求:
2.题目代码:
class Checkout {
public:deque<int> array;Checkout() {array.clear();}//求最大值int get_max() {if(array.size() == 0){return -1;}else{vector<int> temp(array.begin(),array.end());vector<int> :: iterator it = max_element(temp.begin(),temp.end());return *it;}}//尾部插入void add(int value) {array.push_back(value);}//移除头部元素int remove() {if(array.size() == 0){return -1;}else{int temp = array[0];array.pop_front();return temp;}}
};/*** Your Checkout object will be instantiated and called as such:* Checkout* obj = new Checkout();* int param_1 = obj->get_max();* obj->add(value);* int param_3 = obj->remove();*/