a more neat version

for dp solution, first ini, then traversal