单调栈与单调队列
bootdubbo
这个作者很懒,什么都没留下…
展开
-
P2698 [USACO12MAR]花盆Flowerpot 【单调队列】
Farmer John has been having trouble making his plants grow, and needs your help to water them properly. You are given the locations of N raindrops (1 <= N <= 100,000) in the 2D plane, where y re...原创 2019-11-05 12:38:42 · 384 阅读 · 0 评论 -
D. Balanced Playlist【单调队列】
Your favorite music streaming platform has formed a perfectly balanced playlist exclusively for you. The playlist consists of n tracks numbered from 1 to n. The playlist is automatic and cyclic: whene...原创 2019-10-19 11:05:51 · 422 阅读 · 0 评论 -
HDU - 6319 Problem A. Ascending Rating【单调队列】
Before the start of contest, there are n ICPC contestants waiting in a long queue. They are labeled by 1 to n from left to right. It can be easily found that the i-th contestant’s QodeForces rating is...原创 2019-10-08 21:12:23 · 133 阅读 · 0 评论 -
Paint the Digits
You are given a sequence of n digits d1d2…dn. You need to paint all the digits in two colors so that:each digit is painted either in the color 1 or in the color 2;if you write in a row from left to ...原创 2019-09-16 22:18:22 · 184 阅读 · 0 评论 -
A-All-one Matrices【单调栈裸题】
比赛没做出来,有点遗憾具体看代码吧#include<bits/stdc++.h>using namespace std;#define maxn 3010#define INF 0x3f3f3f3ftypedef long long ll;int mp[maxn][maxn],h[maxn][maxn],mx[maxn][maxn],l[maxn],r[maxn];in...原创 2019-08-10 21:26:03 · 143 阅读 · 0 评论 -
C-sequence【线段树+单调栈】
找出左边第一个比ai小的数的位置li与右边第一个比ai小的数的位置ri#include<bits/stdc++.h>using namespace std;#define maxn 3000010typedef long long ll;ll INF=1e18;struct Tree{ int l,r; ll mi,mx;}tree[maxn<<2];...原创 2019-08-09 13:49:14 · 268 阅读 · 0 评论 -
HDU-3410 Passing the Message【单调栈】
What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten are prepared to have an excursion. Before kicking off, teacher Liu tells them to stand in a row. Teach...原创 2019-08-02 14:24:57 · 142 阅读 · 0 评论 -
HDU-3415 Max Sum of Max-K-sub-sequence 【单调队列】
Given a circle sequence A[1],A[2],A[3]…A[n]. Circle sequence means the left neighbour of A[1] is A[n] , and the right neighbour of A[n] is A[1].Now your job is to calculate the max sum of a Max-K-sub...原创 2019-08-02 13:15:00 · 180 阅读 · 0 评论 -
HDU-5178 pairs 【二分】
Problem DescriptionJohn has n points on the X axis, and their coordinates are (x[i],0),(i=0,1,2,…,n−1). He wants to know how many pairs<a,b> that |x[b]−x[a]|≤k.(a<b)InputThe first line con...原创 2019-08-02 11:52:37 · 124 阅读 · 0 评论 -
HDU-5672 String(尺取法)
There is a string S.S only contain lower case English character.(10≤length(S)≤1,000,000)How many substrings there are that contain at least k(1≤k≤26) distinct characters?InputThere are multiple tes...原创 2019-08-02 11:37:48 · 111 阅读 · 0 评论 -
HDU-1506 Largest Rectangle in a Histogram【单调栈】
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 ...原创 2019-08-02 15:38:54 · 71 阅读 · 0 评论 -
POJ-3685 Matrix
Given a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i2 + 100000 × i + j2 - 100000 × j + i × j, you are to find the M-th smallest element in the matrix.I...原创 2019-07-20 21:16:56 · 161 阅读 · 0 评论 -
CodeForces-343C Read Time
Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data in parallel.When viewed from the side, Mike’s hard drive is an ...原创 2019-07-20 20:13:52 · 201 阅读 · 0 评论 -
CodeForces-371C Hamburgers
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread,...原创 2019-07-20 19:45:05 · 152 阅读 · 0 评论