
单调队列
文章平均质量分 78
RJ28
小学生
展开
-
Fzu-2190 非提的救赎 (单调栈)
Problem Description正如你所知道从前有一个人叫s_sin,她拥有着坐拥三千舰狼的梦想!然而天不遂人愿当她踏进hentai collection的大门之后,现实让她领略到了无情。身为一个坚强的妹子,她知道即使出门大破,即使十一连抽全是R,也要坚信着“玄不救非,氪不改命”,而自己是一个欧白这样最初的信仰!有一天s_sin率领着她的舰狼们到达了某海峡,以一个N*M的原创 2016-05-04 17:12:35 · 679 阅读 · 0 评论 -
CCNU校赛2017 - F 康康撩妹(斜率DP)
分析:大概就是f[i][j] = min (f[k][j-1] + w[k+1][i])这种形式的DP,我们把w函数拆开可以得到一个斜率为-dis[i][n]的等式,随着i的增大斜率也在不断增大,所以我们维护一个下凸的决策队列,这样能把转移复杂度优化到O (1).题目链接:https://acm.whu.edu.cn:8443/problem/663#include #define IN原创 2017-05-08 23:08:21 · 581 阅读 · 0 评论 -
Hdu-2770 Easy Climb(DP优化)
Somewhere in the neighborhood we have a very nice mountain that gives a splendid view over the surrounding area. There is one problem though: climbing this mountain is very difficult, because of rathe原创 2017-03-22 10:21:52 · 457 阅读 · 0 评论 -
LA 4726 Average(单调队列)
题意:求连续的子序列使得平均数最大。分析:按照《浅谈数形结合思想在信息学竞赛中的应用》中的做法,维护一个下凸的决策区间,但是注意原作者提到单调栈做法并不是指决策是随着右端点单调的,而是指最优解是随着左端点单调的。#include#include#include#include#include#include#include#include#i原创 2016-08-03 21:06:17 · 315 阅读 · 0 评论 -
BZOJ-1010 [HNOI2008]玩具装箱toy (DP斜率优化)
Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京。他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中。P教授有编号为1...N的N件玩具,第i件玩具经过压缩后变成一维长度为Ci.为了方便整理,P教授要求在一个一维容器中的玩具编号是连续的。同时如果一个一维容器中有多个玩具,那么两件玩具之间要加入一个单位原创 2016-07-15 22:31:10 · 639 阅读 · 0 评论 -
POJ-1821 Fence(单调队列优化DP)
DescriptionA team of k (1 <= K <= 100) workers should paint a fence which contains N (1 <= N <= 16 000) planks numbered from 1 to N from left to right. Each worker i (1 <= i <= K) should sit in fron原创 2016-06-11 11:50:52 · 519 阅读 · 0 评论 -
LA 4254 Processor (单调队列 + 二分)
题意:有n个任务,每个任务有三个参数,ri,di,wi,表示在ri di之内需要执行完工作量为wi的任务,任务可以分块执行,求执行过程中的最大速度的最小值。速度需为整数。分析:二分判断,判断有些复杂,要用到单调队列,写的挺烂的,但是一遍过了。#include #include #include #include #include #define MAXN 10002原创 2016-04-25 21:21:35 · 960 阅读 · 0 评论 -
Codeforces Round #189 (Div. 1) B. Psychos in a Line
There are n psychos standing in a line. Eachpsycho(心理分析) isassigned(分配) aunique(独特的)integer(整数) from1 to n. At each step every psycho who has an id greater than the psycho to his right (if e原创 2016-05-20 15:38:57 · 730 阅读 · 0 评论 -
LA 4327 Parade (DP单调队列)
题目大意:有n+1条横线,m+1条竖线,你的任务是从最南边的路走到最北边的路,使得走过的路上的高兴值和最大。同一段路不能走超过两次,且不能从北往南走,另外每条横向路上所花的时间不能超过k分析:DP+单调队列优化。#include #include #include #include #include #define MAXN 0x3f3f3f3fusing n原创 2016-06-01 17:17:44 · 590 阅读 · 0 评论 -
LA 3983 Robotruck
白书原题,简单的单调队列。#include #include #include #define MAXN 100010using namespace std;int t,T,c,n,x[MAXN],y[MAXN],d[MAXN],f[MAXN],dis[MAXN],q[MAXN],w[MAXN]; int main(){ cin.sync_with_stdio(false);原创 2016-04-23 13:40:33 · 470 阅读 · 0 评论 -
Hdu-5289 Assignment (二分+RMQ || 单调队列)
Problem DescriptionTom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task原创 2016-05-29 10:51:49 · 388 阅读 · 0 评论 -
Hdu-6052 To my boyfriend(单调栈)
Dear Liao I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you teach me?". I replied with a smile, "of course". You replied:"Given a matrix,原创 2017-07-28 00:44:54 · 1760 阅读 · 6 评论