solved one simple dp problem