线段树
寒山寺水杯
这个作者很懒,什么都没留下…
展开
-
康康线段树
线段树是一种二叉搜索树,它可以将一个区间划分为一些单元区间,每个单元区间对应线段树中的一个叶节点。 对于线段树中的每一个非叶子节点[a,b],它的左儿子表示的区间为[a,(a+b)/2],右儿子表示的区间为[(a+b)/2+1,b],所以线段树是平衡二叉树,最后的子节点数目为N,即整个线段树区间的长度。 ...原创 2020-02-25 16:57:25 · 106 阅读 · 0 评论 -
Minimum Inversion Number
The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, …, an, if we move the first ...原创 2020-02-25 15:26:01 · 82 阅读 · 0 评论 -
Balanced Lineup
For the daily milking, Farmer John’s N cows (1 ≤N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things s...原创 2020-02-21 17:17:10 · 108 阅读 · 0 评论 -
Just a Hook
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge w...原创 2020-02-20 17:34:40 · 115 阅读 · 0 评论 -
I Hate It
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M(0<N<=200000 ,0<M<5000 ),...原创 2020-02-18 17:22:25 · 84 阅读 · 0 评论