1D dp by michael kolupaev [2169284]