class StockSpanner {
int k = 1;//记录天数
stack<pair<int, int>> stk;
public:
StockSpanner() {
stk.push({0, INT_MAX});
}
int next(int x) {
while (x >= stk.top().second)
stk.pop();
int res = k - stk.top().first;
stk.push({k, x});
k ++ ;
return res;
}
};