Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:这题线段树怎么做?In Reply To:这题线段树怎么做? Posted by:SherlockBourne at 2007-09-25 13:03:50 > 我只想出保存声音最大值和最小值的方法……tle了…… 线段树的做法…… 首先按x从小到大排序 将x的值插入 节点记录x的sum 然后按v从大到小排序 然后对cow数组扫一遍 由于cow的位置已经确定 所以可以在o(lg(n))时间内确定x前面和后面的距离和(根据节点的sum) 算出总的dis,乘以v即可 然后在线段树中删除这个x cow数组扫完便得到答案 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator