题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those with higher index numbers. We say that cow…
题目链接:https://www.luogu.org/problemnew/show/P2947 因为在单调队列上被dalao们锤爆 怒刷单调队列题 何为单调队列? 设我们的队列为从左至右单调递增 对于样例数据 3 2 6 1 1 2 我们先把3入队 此时队列:3 再将2从后面入队 此时队列:2 3 再将6从后面入队 但是,为了满足队列从左至右的单调性,我们将2,3出队 此时队列:6 再将1从后面入队 此时队列:1 6 再将1从后面入队 此时队列:1 1 6 再将2从后面入队 但是,为了满足队列…
单调栈真的很好用呢! P2947 [USACO09MAR]向右看齐Look Up 题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those wi…
题目链接: https://www.luogu.org/problemnew/show/P1776 题目: 终于,破解了千年的难题.小FF找到了王室的宝物室,里面堆满了无数价值连城的宝物……这下小FF可发财了,嘎嘎.但是这里的宝物实在是太多了,小FF的采集车似乎装不下那么多宝物.看来小FF只能含泪舍弃其中的一部分宝物了……小FF对洞穴里的宝物进行了整理,他发现每样宝物都有一件或者多件.他粗略估算了下每样宝物的价值,之后开始了宝物筛选工作:小FF有一个最大载重为W的采集车,洞穴里总共有n种宝物,每…
Solution 二维单调队列, 这个数组套起来看得我眼瞎... Code #include<cstdio> #include<algorithm> #include<cstring> #define rd read() #define rep(i,a,b) for(register int i = (a); i <= (b); ++i) #define per(i,a,b) for(register int i = (a); i >= (b); --i)…
题目链接 不知为何状态突然奇差无比,按说这题本来应该是水题的,但不仅不会做,还比着题解爆零五次 二分平均值(想到了),单调队列维护最大区间和(想到了但是不会,???为什么我不会???) #include<cstdio> #include<algorithm> #include<cctype> #include<cstring> #include<cstdlib> #define maxn 200020 #define eps 1e-6 using…
题目链接 这题各种边界判断恶心死人 就是单调队列在每行求出最小的.能装进A*B方块里的花坛 然后再在刚刚求出的那个东西里面跑一遍竖着的单调队列 然后……边界调了一小时 做完这题我深刻地感觉到我又强了 #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cctype> #include<queue> #include<v…
P3572 [POI2014]PTA-Little Bird 题目描述 In the Byteotian Line Forest there are nn trees in a row. On top of the first one, there is a little bird who would like to fly over to the top of the last tree. Being in fact very little, the bird might lack the s…
题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those with higher index numbers. We say that cow…
目录 题目 思路 \(Code\) 题目 戳 思路 单调栈裸题 \(Code\) #include<stack> #include<cstdio> #include<string> #include<cstring> #include<iostream> #define MAXN 100001 #define rr register using namespace std; int n,ans[MAXN]; struct mu{ int num,…