Please Hack my solution,Chef and DAG

I don’t really understand where I am going wrong , could anyone help me with this?
https://www.codechef.com/viewsolution/30348726