HDU 5115 Dire Wolf
I had a question about the last field competition in Beijing. I made a short interval dp yesterday. I suddenly remembered this question. It was very similar and I did it.
At first, just like what I did yesterday, I always thought about how to reverse push. Later I found that this question should be being pushed.
In fact, the positive push and reverse push seem very similar, only one is dp [I] [j], which indicates that I, j, and other wolves are used to eliminate the cost of I-j, one is to eliminate the cost when only I-j is left.
Sum up the similarities between the dp in the interval yesterday and the dp in today's interval. It is found that the cost of the interval dp will change with the passage of time or the change of the dp.
#include
#include#include
using namespace std;const int inf=999999999;int a[205],b[205];int dp[205][205],n;void init(){for(int i=0;i<205;i++){for(int j=0;j<205;j++){dp[i][j]=inf;}}b[n+1]=0;for(int i=1;i<=n;i++) dp[i][i]=a[i]+b[i-1]+b[i+1];for(int i=1;i