Hexagonal Tiling
시간 제한4초메모리 제한1024 MB
변 길이가 N인 정육각형을 단위 마름모로 빈틈없이 채우되, 놓을 수 있는 각 마름모 위치마다 비용이 주어질 때 전체 비용의 최솟값을 구한다.
문제
You are given a regular hexagon having sides of length . A regular hexagon can be split into unit equilateral triangles of side length as shown in the figure below. We are going to completely fill the hexagon with unit rhombuses of side length formed by joining two equilateral triangles which share an edge.

Hexagon formed from triangles
For each position a unit rhombus can be placed, the cost of placing a rhombus is given. Find the minimum cost required to fill the hexagon.
입력
The first line of input contains .
The following lines contain the cost for a rhombus placed in each respective row.
Let’s say the cost of a rhombus formed by joining the -th and -th triangles of the -th row is .
The -th of the lines of input contains .
The next lines of input contain the cost for a rhombus placed across two rows.
Let’s say the cost of a rhombus formed by joining the -th inverted triangle of the -th row and the triangle above it is .
The -th of the lines contains .
출력
Print the minimum cost required to fill the hexagon using unit rhombuses. It can be proved that it is always possible to fill a hexagon using unit rhombuses.
제한
힌트

The costs of rhombuses given in example 1

The solution for example 2