http://codeforces.com/contest/1257/problem/D
简单dp问题
转发一个博客
https://www.cnblogs.com/QingyuYYYYY/p/11863747.html