capimove time

some help needed to deal with time complexcity,any suggestion which algorithm should i use to decrease the time ,or some problems in codechef which can help me dealing tle.

//