My first 500 pt div2 problem (solved with DP)