Comments

Actually, you don't need the first transition at all. Taking a voter for free is covered by the second transition, and cases when team value for some states is larger than needed are handled by the nature of DP automatically. You only decrease the number of extra votes by paying the voters (as in the third transition).

The successful submission of your code without the first transition http://mirror.codeforces.com/contest/1251/submission/63500118