How do I optimise this? I'm getting TLE

I’m getting TLEs on this sol (https://pastebin.com/Dnpkq0dq) of problem(https://www.codechef.com/FLPAST01/problems/MAY19F1). please help me out.
Edit: I couldn’t see other solutions as the ques is from ccdsap past year test. sols arn’t visible.
Edit: sol wasn’t visible so I’ve provided a new link

You code not visible.
Upload it somewhere else and provide link. :slight_smile:

2 Likes

https://pastebin.com/Dnpkq0dq

100 pts simple code : here using a set

1 Like

Simple Easy and Understandable Complexity O(n)
https://www.codechef.com/viewsolution/28516185

thanks alot

your code isn’t visible, can you paste it here?

well a small observation would help u here, the thing is after score i is known the maximum is either the present number or the maximum till the last number.
max_after_(i)=max(i,max_after_(i-1))
probably using a map in c++ would do just fine

I am sorry
https://pastebin.com/GNpd6Afc

1 Like