Today I was solving this problem.
I made two similar submissions.
Sub1 used class ( TLE ).
Sub2 exact same code without class ( AC ).
I can't understand why making the functions and variables as class's member consuming so much time?
I have googled but didn't find anything written about it.