poj 1160 dp?四边形不等式

看到ac人次我就隐隐感觉不对。。。
四边形不等式的题没有四边形不等式?
老婆饼没老婆???

#define int ll

int n, m, a[333], f[33][333], sum[333];

signed main() {
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%lld", a + i), sum[i] = sum[i - 1] + a[i];
	memset(f, LINF, sizeof(f));
	for (int i = 0; i < 33; i++)f[i][0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 0; k < j; k++) {
				int pos = k + (j - k + 1) / 2;
				int w = (pos - k)*a[pos] - (sum[pos] - sum[k]);
				w += sum[j] - sum[pos] - (j - pos)*a[pos];
				f[i][j] = min(f[i][j], f[i - 1][k] + w);
			}
		}
	}
	printf("%lld\n", f[m][n]);

	return 0;
}

你可能感兴趣的:(算法-dp,算法)