What's wrong in the code?!(Getting TLE)

Code-:Submission #144914774 - Codeforces
Question-:Problem - B - Codeforces

Please help me …I am stuck on this question for a long time

I think you should use vector

.