『算法-ACM竞赛』单调栈(模板) 『算法-ACM 竞赛』单调栈(模板)123456789101112131415a[n + 1] = p = 0;for (int i = 1; i <= n + 1; i++) {if (a[i] > s[p]) {s[++p] = a[i], w[p] = 1;} else {int width=0;while (s[p] > a[i]) {width += w[p];ans = max(ans, (long long)width \* s[p]);p--;}s[++p] = a[i], w[p] = width + 1;}} 算法 > ACM竞赛 『算法-ACM竞赛』单调栈(模板) https://chiamzhang.github.io/2024/06/29/『算法-ACM竞赛』单调栈(模板)/ Author Chiam Posted on June 29, 2024 Licensed under 『算法-ACM竞赛』单调队列模板 Previous 『算法-ACM竞赛』关于RMQ问题的四种解法 Next Please enable JavaScript to view the comments