Interval DP, cut DP[I][J] is not cost-independent (no validity)
DP[I][J] represents the cost of interval i,j, so as long as the enumeration of the cutting method is done, the interval is divided into smaller intervals. O (n^3)
Looked at the quadrilateral inequalities, proved too long.
#include <bits/stdc++.h>//variables don't take ignore left or something like that.using namespacestd;Const intMAXN =Wuyi;intCUT[MAXN];intDP[MAXN][MAXN];Const intINF =0x3fffffff;intMain () {//freopen ("In.txt", "R", stdin); intL,n; while(SCANF ("%d",&l) {scanf ("%d",&N); cut[0] =0; cut[n+1] =L; for(inti =1; I <= N; i++) scanf ("%d", cut+i); for(inti =0; I <= N; i++) dp[i][i+1] =0; for(intD =1; D <= N; d++){ for(inti =0, MI = n-d; I <= mi; i++){ intj = i+d+1; DP[I][J]=INF; for(intK = i+1; K < J; k++) {Dp[i][j]= Min (dp[i][j],dp[i][k]+Dp[k][j]); } Dp[i][j]+ = cut[j]-Cut[i]; }} printf ("The minimum cutting is%d.\n", dp[0][n+1]); } return 0;}
UVA 10003 cuting Sticks cut sticks