Help in range query problem

I have come across this problem,

Its a nice technique somewhat similar to mo’s algo. I was wondering, can we also able to achieve this problem (in nlogn) but with update query as well?