Given a cube with size x*y*z. each vertex has a non-negative weight w(x, y, z). As shown in figure 1, a surface-carving is a curved section on the XOY plane, and it has two properties:
Figure 1. The cube and the surface-carving example
1. Surface F is formed of x*y vertices, and there is one and only one vertex in each Z axis belonging to the surface.
2. For each vertex (x, y, z) on the surface,its XOY plane adjacent vertices(x+1, y, z’) or (x-1, y, z’) or (x, y+1, z’) or (x, y-1, z’) satisfy that |z- z’|<=1.
Define the energy of the surface F as the sum of the vertices value on it.
Please obtain the minimum value of the surface energy.