![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
单调栈
ssl_yty
这个作者很懒,什么都没留下…
展开
-
【51nod】【单调栈】扔盘子
【51nod】【单调栈】扔盘子题目 解题思路因为井的宽度是不确定的先将其处理成一个下降序列 (因为如果a1<a2,一个比a1大的盘也一定不会去到a2)接着一个一个丢盘子,记录所到的高度,如果到0就结束代码#include<iostream>#include<cstdio>using namespace std;int n,m,y,x,t,ans,a[500010],q[500010];int main(){ scanf("%d%d",&n原创 2022-01-14 08:01:07 · 99 阅读 · 0 评论 -
【51nod】【单调栈】 移掉k位数字
【51nod】【单调栈】 移掉k位数字题目解题思路手推一下就知道要删掉山峰(就是两边的数都比它小)用单调栈一旦碰到栈顶比当前大,就弹出栈顶(也就是将栈顶在数中移掉)要注意如果最后一段是升序且没删完k位,要继续弹出栈顶输出时要处理掉前导0代码#include<iostream>#include<cstdio>using namespace std;char c;int x,n,m,t,k,a[10010],q[10010];int main(){原创 2022-01-13 21:09:57 · 178 阅读 · 0 评论 -
【ybtoj 高效进阶 5.6】【单调栈】 最大矩阵
【ybtoj 高效进阶 5.6】【单调栈】 最大矩阵解题思路用单调栈找出以a[i]为高能到达的最左边和最右边然后求出最大面积代码#include<iostream>#include<cstdio>using namespace std;int n,a[100010],q[100010],t,you[100010],zuo[100010];long long ans;int main(){ scanf("%d",&n); for (int i=原创 2022-01-11 22:03:44 · 162 阅读 · 0 评论 -
POJ 2796 Feel Good
POJ 2796 Feel GoodPOJ 2796题目Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people’s memories about some period of life.A new idea Bill has recently deve原创 2020-08-12 21:14:16 · 69 阅读 · 0 评论 -
POJ 3494 Largest Submatrix of All 1’s 题解
POJ 3494 Largest Submatrix of All 1’s 题解POJ 3494题目Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements.输入The input contains multiple test cases. Each test cas原创 2020-08-12 20:41:24 · 178 阅读 · 0 评论 -
POJ 2559 Largest Rectangle in a Histogram 题解
POJ 2559 Largest Rectangle in a Histogram 题解POJ 2559题目A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows原创 2020-08-12 19:45:26 · 267 阅读 · 0 评论 -
排队 题解
排队 题解排队题目nnn个人排成一条直线(一排),给出队伍中每个人的身高,每个人只能看到站在他右边且个头比他小没有被其他人挡住(跟他身高相同也会挡出他)的人。请求出所有人可以看到的人数之和。1<=NNN<=80,000样例input610374122output5解题思路单调栈单调维护一个递增或递减的序列(与单调队列不一样,只能由一头出栈)如果当前的比栈顶的小就使栈顶出栈栈顶的编号减当前的编号就是能看到的人数最终答案累加代码#include&原创 2020-08-12 14:59:37 · 1840 阅读 · 0 评论