1
2
int inf = 2e9;
struct sliding_window{
vector<int> l, r;
int rmin;
sliding_window(){
rmin = inf;
}
void push_back(int x){
r.push_back(x);
rmin = min(rmin, x);
}
void pop_front(){
if(l.empty()){
for(int mn = inf; !r.empty();){
mn = min(mn, r.back());
l.push_back(mn);
r.pop_back();
}
rmin = inf;
}
l.pop_back();
}
int get_min(){
int res = rmin;
if(!l.empty()) res = min(res, l.back());
return res;
}
};