查了半天没看出来,有人能帮我查一下吗 ,谢谢

P1220 关路灯

yourenma
by 梦理乾坤 @ 2020-07-28 17:24:01


@[rubbish](/user/107232)
by 梦理乾坤 @ 2020-07-28 17:24:18


@[•╬•](/user/119552) ```cpp for (int l = 2; l <= n; l ++ ) for (int i = 1; i + l - 1 <= n; i ++ ) { int j = i + l - 1; f[i][j] = min(f[i + 1][j] + (a[i + 1] - a[i]) * (sum[i] + sum[n] - sum[j]), g[i + 1][j] + (a[j] - a[i]) * (sum[i] + sum[n] - sum[j])); g[i][j] = min(f[i][j - 1] + (a[j] - a[i]) * (sum[i - 1] + sum[n] - sum[j - 1]), g[i][j - 1] + (a[j] - a[j - 1]) * (sum[i - 1] + sum[n] - sum[j - 1])); } ``` 中第5、6行 f[i][j]的值 ```cpp f[i][j] = min(f[i + 1][j] + (a[i + 1] - a[i]) * (sum[i] + sum[n] - sum[j]), g[i + 1][j] + (a[j] - a[i]) * (sum[i] + sum[n] - sum[j])); ``` 改为 ```cpp f[i][j] = min(f[i + 1][j] + (a[i + 1] - a[i]) * (sum[i] + sum[n] - sum[j]), f[i + 1][j] + (a[j] - a[i]) * (sum[i] + sum[n] - sum[j])); ``` 也就是把g改成f
by LaoPi @ 2020-07-28 19:46:19


抠细节
by LaoPi @ 2020-07-28 19:46:53


谢谢
by 梦理乾坤 @ 2020-07-28 20:12:50


|