拓展:单调栈
2020-02-02 19:45
155 查看
传送门:单调栈
板子:
#include<iostream> #include<algorithm> #include<stack> using namespace std; const int N=100010; stack<int> st; int main() { ios::sync_with_stdio(false); int n,x; cin>>n; while(n--) { cin>>x; while(st.size()&&st.top()>=x) st.pop(); if(st.empty()) cout<<-1<<" "; else cout<<st.top()<<" "; st.push(x); } return 0; }
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 17 单调递增最长子序列
- PHP GD库添加freetype拓展的方法
- poj 2823(单调队列)
- BZOJ4476 JSOI2015送礼物(分数规划+单调队列)
- HDU 5380 Travel with candy (贪心,单调队列)
- VSCode拓展推荐(前端开发)
- POJ 1703 Find them, Catch them(并查集拓展)
- wxPython(二)功能拓展
- POJ 1061 青蛙的约会(拓展的欧几里得)
- 单调队列和单调栈
- 拓展欧几里得 专题
- UVALive - 3983 - Robotruck (DP+单调队列)
- ES6新特性(1)解构赋值:对象的解构赋值,拓展运算符
- 【Unity游戏开发之八】Unity利用语法糖添加自定义拓展方法(下)
- leetcode 896单调数列
- ssoj1589Pilots(单调队列)
- 显示Windows10中的文件拓展名---------16岁的小前端
- UIColor的使用及拓展