Hello guys,Few days ago this question was asked in Codechef cookoff.I was able to understand greedy part of the editorial but could not convince myself with DP approach.
Things I did not understand, In the picking of Pairs,where are we checking the conditions in which pair's difference is strictly less than D.I could not see it anywhere.
So basically I want you to please explain it to me.The more detailed the more helpful(as I am dumb :P).Thank you have a nice day.
[](https://discuss.codechef.com/questions/72500/sumpair-editorial)