problem link : http://www.codechef.com/problems/CHMOD
I've done exactly the same thing as in the editorial: http://discuss.codechef.com/questions/20312/chmod-editorial
still my solution:http://www.codechef.com/viewsolution/3914314 gives TLE. After a lot of attempts i am unable to correct it. Since my logic is correct ,i have to know error in my code and learn from it,and i cant leave it unsolved. any help is appreciated