This is what I would do in contest:-
-
O(N) , if it fails,
2)A nice formula comes from the dp we apply, just paste it
This is what I would do in contest:-
This is pleasant to my eyes.
O(N * T) actually passed with 0.1 secs.
I actually wasnt in the contest but few guys said that it TLEβs so I was trying to reason. You are correct. It should pass.
It creates TLE, I tried it. We will need better algorithm.