How do I optimise this? I'm getting TLE

I’m getting TLEs on this sol (#include <bits/stdc++.h>#define ll long longusing namespace std;int arr[10 - Pastebin.com) of problem(CodeChef: Practical coding for everyone). 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

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

1 Like