记录最大值
class MaxQueue {
public:
dequeq1;
int order=0;
MaxQueue() {}
int max_value() {
if(q1.empty())return -1;
int n=q1.size();
for(int i=order;i
q1.push_back(value);
}
int pop_front() {
if(q1.empty())return -1;
if(order!=0)order--;
int a=q1[0];
q1.pop_front();
return a;
}
};
暴力解
class MaxQueue {
public:
vectorq1;
MaxQueue() {}
int max_value() {
if(q1.empty())return -1;
auto a=q1;
sort(a.begin(),a.end());
return a.back();
}
void push_back(int value) {
q1.push_back(value);
}
int pop_front() {
if(q1.empty())return -1;
int a=q1[0];
q1.erase(q1.begin());
return a;
}
};



