XKC's basketball team【线段树查询】】的更多相关文章

XKC's basketball team XKC , the captain of the basketball team , is directing a train of nn team members. He makes all members stand in a row , and numbers them 1 \cdots n1⋯n from left to right. The ability of the ii-th person is w_iwi​ , and if ther…
XKC's basketball team 题意:给定一个序列,从每一个数后面比它大至少 \(m\) 的数中求出与它之间最大的距离.如果没有则为 \(-1\). 题解:从后向前维护一个递增的队列,从后往前遍历,若当前的数大于队尾就进队,否则从该队列中二分找最小的比自己大至少 \(m\) 的数,二者之间的距离即为答案. 若当前数小于队尾,那这个数一定没有队尾的数优,因为它既比队尾的数靠前,又比它小. 时间复杂度 \(O(nlogn)\) . 此题也可以用ST表+二分 等方法写出. 标程(单调队列)…
题目4 : 80 Days 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 80 Days is an interesting game based on Jules Verne's science fiction "Around the World in Eighty Days". In this game, you have to manage the limited money and time. Now we simplified the game…
XKC , the captain of the basketball team , is directing a train of nn team members. He makes all members stand in a row , and numbers them 1 \cdots n1⋯n from left to right. The ability of the ii-th person is w_iwi​ , and if there is a guy whose abili…
线段树属于二叉树, 其核心特征就是支持区间加法,这样就可以把任意待查询的区间$[L, R]$分解到线段树的节点上去,再把这些节点的信息合并起来从而得到区间$[L,R]$的信息. 下面证明在线段树上查询任意区间的复杂度是$O(\log{N})$的,$N$是区间总长度. 由于访问一个节点(即获得一个节点内与待查询区间$[L, R]$相关的信息)是$O(1)$的,只要证明查询一个区间要访问的节点数是$O(\log{N})$的. 如果某个节点完全包含在$[L,R]$内,则不会再向下查询,我们称这样的节点…
L3-002. 堆栈 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 大家都知道“堆栈”是一种“先进后出”的线性结构,基本操作有“入栈”(将新元素插入栈顶)和“出栈”(将栈顶元素的值返回并从堆栈中将其删除).现请你实现一种特殊的堆栈,它多了一种操作叫“查中值”,即返回堆栈中所有元素的中值.对于N个元素,若N是偶数,则中值定义为第N/2个最小元:若N是奇数,则中值定义为第(N+1)/2个最小元. 输入格式: 输入第一行给出正整…
描述 In the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R) (L<=R), we report the minimum value among A[L], A[L+1], …, A[R]. Note that the indices start from 1, i.e. the left-most element is A[1]. In…
题目链接: C. Foe Pairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   You are given a permutation p of length n. Also you are given m foe pairs (ai, bi) (1 ≤ ai, bi ≤ n, ai ≠ bi). Your task…
XKC , the captain of the basketball team , is directing a train of nn team members. He makes all members stand in a row , and numbers them 1 \cdots n1⋯n from left to right. The ability of the ii-th person is w_iwi​ , and if there is a guy whose abili…
C. Hotel 旅馆 内存限制:256 MiB 时间限制:1000 ms 标准输入输出 题目类型:传统 评测方式:文本比较   题目描述 OIER最近的旅游计划,是到长春净月潭,享受那里的湖光山色,以及明媚的阳光.作为整个旅游的策划者和负责人,贝茜选择在湖边的一家著名的旅馆住宿.这个巨大的旅馆一共有N 间客房,它们在同一层楼中顺次一字排开,在任何一个房间里,只需要拉开窗帘,就能见到波光粼粼的湖面. 所有的旅游者,都是一批批地来到旅馆的服务台,希望能订到 间连续的房间.服务台的接待工作也很简单:…