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,如需转载请自行联系原作者

相关文章
|
7月前
|
前端开发 JavaScript 测试技术
【PTA】L1-32 Left-pad (C++)
【PTA】L1-32 Left-pad (C++)
45 0
【PTA】L1-32 Left-pad (C++)
|
vr&ar
CF482B. Interesting Array(线段树)
CF482B. Interesting Array(线段树)
64 1
CF711D-Directed Roads(组合数学 dfs找环)
CF711D-Directed Roads(组合数学 dfs找环)
86 0
CF711D-Directed Roads(组合数学 dfs找环)
CF1365D Solve The Maze (BFS)
CF1365D Solve The Maze (BFS)
86 0
CF1365D Solve The Maze (BFS)
CF 1156D. 0-1-Tree(树形DP)
CF 1156D. 0-1-Tree(树形DP)
102 0
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
CF1454 E. Number of Simple Paths (基环树 拓扑排序)
92 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.
142 0
Tree with Maximum Cost---CF1092F 树上DP
|
算法 C# 索引
算法题丨Move Zeroes
描述 Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
1170 0