Initial version.
TLE on test #17.
TLE on test #28.
Added member variable N.
AC version, using DP memoization on demand to speed up.
Code for problem 39C.