SRM 197 Div II 1100 pointer. Brute force-exponential

Will try with dp matrix chain.