Edtorial request for Spoj K Query II

Can anyone provide a detail editorial to solve spoj k query II https://www.spoj.com/problems/KQUERY2/

If anyone solved this problem using sqrt decompositon + BIT. please give me idea how to solve it using sqrt decomposition + BIT