
树状数组
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【CodeForces - 460C】Present(二分+树状数组)
题干:给定N朵花的原先的高度,从左到右排列,最多浇水m天,每天只能浇一次,每次使得连续的w朵花的高度增长1,问最后最矮的花的高度最高是多少。ExamplesInput6 2 32 2 2 2 1 1Output2Input2 5 15 8Output9NoteIn the first sample beaver can water...原创 2019-10-14 19:16:52 · 294 阅读 · 0 评论 -
【2018ACM山东省赛 - E】Sequence(树状数组,思维,优化)
题干:We define an element aia_iai in a sequence "good", if and only if there exists a j(1≤j<i)j(1\le j < i)j(1≤j<i) such that aj<aia_j < a_iaj<ai.Given a permutation ppp of integ...原创 2019-05-09 21:27:24 · 425 阅读 · 0 评论 -
【蓝桥杯官网试题 - 历届试题】小朋友排队(逆序数,树状数组)
题干:问题描述 n 个小朋友站成一排。现在要把他们按身高从低到高的顺序排列,但是每次只能交换位置相邻的两个小朋友。 每个小朋友都有一个不高兴的程度。开始的时候,所有小朋友的不高兴程度都是0。 如果某个小朋友第一次被要求交换,则他的不高兴程度增加1,如果第二次要求他交换,则他的不高兴程度增加2(即不高兴程度为3),依次类推。当要求某个小朋友第k次交换时,他的不高兴程度增加k。 ...原创 2019-04-08 16:37:42 · 471 阅读 · 0 评论 -
【csust】最小素因子问题(树状数组)
题干:http://csustacm.com:4803/problem/1083Description寒冰射手艾希新学会了一个技能,艾希通过这个技能成为了一名声名远扬的神箭手,从此再也无人敢侵犯弗雷尔卓德!这个技能的描述如下(假设英雄联盟内的每个人都有一个编号):假设艾希有x-1(x>=2)x−1(x>=2)个敌人,每个敌人的编号分别为1\;\;1~\;\;x-1x...原创 2019-03-13 14:16:18 · 808 阅读 · 0 评论 -
【SPOJ - DQUERY】D-query(权值树状数组 或 主席树 或 莫队)
题干:Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in...原创 2018-10-08 00:55:15 · 301 阅读 · 0 评论 -
【OpenJ_Bailian - 2299 】Ultra-QuickSort (归并排序 或 离散化 + 树状数组)
题干:In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sor...原创 2018-09-15 13:11:04 · 355 阅读 · 0 评论 -
*【CodeForces - 799C】Fountains (线段树 或 树状数组,类似二元组问题)
题干:Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There arenavailable fountains, for each fountain its beauty and cost are known. There are two types of money in the gam...原创 2018-09-09 01:14:45 · 591 阅读 · 2 评论 -
【HDU - 3974】 Assign the task (dfs序 + 线段树维护 区间更新+ 单点查询)
题干:There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,...原创 2018-08-09 20:35:23 · 378 阅读 · 0 评论 -
【POJ - 3321】 Apple Tree(dfs序 + 线段树维护 或 dfs序 + 树状数组维护)
题干:There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tree h...原创 2018-08-09 19:03:17 · 320 阅读 · 0 评论