CF 295E Yaroslav and Points(Splay)

简介:

题目大意:

两个操作

1 id op  把id的位置+op

2 id op  查询在【id。op】之间的全部的数的差


思路:

关键是pushup函数。

自己退一下会发现。跟区间的总和,区间的节点个数有关。

比方假设左区间是 1 2 的话

右区间来一个 9

那么

就要加上

9-1+9-2 


 

}






本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5280690.html,如需转载请自行联系原作者

相关文章
|
5月前
|
前端开发 JavaScript 测试技术
【PTA】L1-32 Left-pad (C++)
【PTA】L1-32 Left-pad (C++)
38 0
【PTA】L1-32 Left-pad (C++)
|
机器学习/深度学习 人工智能 算法
CF1550A Find The Array(贪心算法)
CF1550A Find The Array(贪心算法)
32 0
LeetCode 149. Max Points on a Line
给定一个二维平面,平面上有 n 个点,求最多有多少个点在同一条直线上。
96 0
LeetCode 149. Max Points on a Line
|
vr&ar
CF482B. Interesting Array(线段树)
CF482B. Interesting Array(线段树)
60 1
CF711D-Directed Roads(组合数学 dfs找环)
CF711D-Directed Roads(组合数学 dfs找环)
80 0
CF711D-Directed Roads(组合数学 dfs找环)
CF1365D Solve The Maze (BFS)
CF1365D Solve The Maze (BFS)
80 0
CF1365D Solve The Maze (BFS)
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
87 0
|
人工智能 BI
CF1169C. Increasing by Modulo(二分)
CF1169C. Increasing by Modulo(二分)
128 0
|
人工智能
Tree with Maximum Cost---CF1092F 树上DP
You are given a tree consisting exactly of n vertices. Tree is a connected undirected graph with n−1 edges. Each vertex v of this tree has a value av assigned to it. Let dist(x,y) be the distance between the vertices x and y.
137 0
Tree with Maximum Cost---CF1092F 树上DP