COCI 2009/2010 Task MALI1. round, 24. october 2009.Author: Marko Ivankovi., Filip BarlMirko and Slavko are playing a new game. Again. Slavko starts each round bygiving Mirko two numbers A and B, both smaller than 100. Mirko then has toslove the following task for Slavko: how to pair all given A numb Read More
posted @ 2012-10-09 21:40 jiai Views(568) Comments(0) Diggs(0) Edit
树状数组(BinaryIndexTree)利用二进制的一些性质巧妙的划分区间,是一种编程,时间和空间上都十分理想的求区间和的算法,同样我们可以利用树状数组优美的区间划分方法来求一个序列的最值约定以num[]表示原数组,以idx[]表示索引数组,Lowbit(x)=x&(-x)树状数组求和时通过构造数组idx[]使idx[k]=sum(num[tk]),tk[k-Lowbit(k)+1,k],使用同样的方法构造最值索引数组:以最大值为例,先讨论询问过程中不对数组做任何修改的情况,用idx[k]记录[k-Lowbit(k)+1,k]区间内的最大值,可以仿照求和时的方法得到:[cpp]vie Read More
posted @ 2012-10-09 20:46 jiai Views(294) Comments(0) Diggs(0) Edit