http://acm.hdu.edu.cn/showproblem.php?pid=3506
Test instructions: Ring stone combined to take minimum = = (n<=1000)
#include <cstdio> #include <algorithm>using namespace Std;const int n=2005, Oo=~0u>>1;int a[n], w[n], D N [N], S[n][n], N;int main () {while (~SCANF ("%d", &n)} {for (int i=1; i<=n; ++i) scanf ("%d", &a[i]), a[i+n]=a[i];n= 2*n;int ans=oo;for (int i=1; i<=n; ++i) w[i]=w[i-1]+a[i];for (int i=1; i<n; ++i) d[i][i+1]=a[i]+a[i+1], s[i][i+1]=i+ 1;for (int len=3; len<=n; ++len) {for (int i=1; i<=n-len+1; ++i) {int j=i+len-1, l=s[i][j-1], r=s[i+1][j], &now=d[ I][J], &pos=s[i][j];now=oo;for (int k=l; k<=r; ++k) {if (Now>=d[i][k-1]+d[k][j]) {now=d[i][k-1]+d[k][j];p os= K;}} NOW+=W[J]-W[I-1];}} for (int i=1; i<= (n>>1); ++i) ans=min (ans, d[i][i+ (n>>1)-1]);p rintf ("%d\n", ans);} return 0;}
Come on, mom. Optimization of the next quadrilateral inequality = =
First, for a class of 2d2d equations:
$$
D (i, j) =
\begin{cases}
Min \{D (i, k-1) +d (k, J) \}+w (I, j) & I<j \ \
0 & i=j \ \
OO & I>j
\end{cases}
$$
(I have not analyzed the $max$, but we can $w (i, J) =-w (I, j) $ and then $max$ take $min$ is good hhh (eh, this should be OK?) ))
We have the theorem below (proof that we can go to the paper or q i = =)
If $i \le i ' \le J \le J ' $ There is $w (i, J) +w (i ', J ') \le W (i ', j) +w (I, J ') $ (quadrilateral inequalities)
And if $i \le i ' \le J ' \le j$ there is $w (i ', J ') \le W (i, j) $ (interval monotonicity)
Set $s (i, j) =max \{K|d (i, J) =d (i, k-1) +d (k, J) +w (i, J) \}$ then there are:
$$
\begin{align}
D (i, J) +d (i ', J ') & \le D (i ', j) +d (I, j ') \ \
S (i, J) \le s (i, j+1) & \le S (i+1, j+1)
\end{align}
$$
and $s$ the value of each $l=j-i+1$ is the average $o (n) $ (I do not understand the proof of the paper AH =) so the equation from $o (n^3) $ down to $o (n^2) $
So the $sum$ of the problem obviously satisfies the quadrilateral inequalities and the interval monotonicity, so the topic becomes the water problem =
"HDU" 3506 Monkey Party