Time limit exceeded

https://www.codechef.com/viewsolution/32029882
How can i make my solution more efficient in terms of time complexity?
@everule1

It’s not easy. You need to learn about lazy propagation in segment trees and coverting linear relations into matrices.
Editorial for the question is here