I can't really make R < B all the time. In my solution, dp[a][b][r] means the maximum set of pair(x, y) such that sum(x) <= b sum(y) <= r and all x >= a
so dp[a][b][r] = max {dp[a + 1][b - (j + 1) * a][r - j * (j + 1) / 2] + j + 1} assuming that the set contains (a, 0) (a, 1) ..... (a, j) which means, dp[a][b][r] is different from dp[a][r][b] The answer is simply dp[0][b][r] given b and r -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/2bea892c-bf30-4a8b-8712-4259bf9c13d0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.