Please Explain the code

https://ide.codingblocks.com/s/223381 Please Explain me why this code is not working

@kt62495,
Because you are greedily choosing between a[i] and a[j], which is not correct. Have you done Wine dp problem, I think you should do that before doing this.