↓ 跳过正文
  1. Tags/

单调队列

2016

hdu 3415 Max Sum of Max-K-sub-sequence (单调队列)

·784 字·2 分钟
hdu 3415 题意:给出n个整数,是一个环(也就是a[n]右边是a[1])求一段长度不超过k的数使得和最大,问最大和是多少并给出这段数的位置。 思路:为了处理环,先把n个数复制一下就好,然后求前缀和sum[i]

ural 1126. Magnetic Storms (单调队列模板题)

·900 字·2 分钟
ural 1126 题意:n个数,求从第k个元素开始,求每k个元素的最大值(一共求n-k+1次) 思路:单调队列。 单调队列学习链接 其实单调队列挺容易的理解的。。。当时觉得写不明白大概是因为看到的代码写得太丑了2333

2015

poj 2823 Sliding Window (单调队列)

·1773 字·4 分钟
Sliding Window 看这个问题:An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves rightwards by one position.Your task is to determine the maximum and minimum values in the sliding window at each position. 也就是有一个数列a,要求你求数列b和c,b[i]是a[i]…a[i+w-1]中的最小值,c[i]是最大值。如果a是1,3,-1,-3,5,3,6,7,则b为-1,-3,-3,-3,3,3,c为3,3,5,5,6,7。