AC 1
using DP with 2d array