Shower Line

题意翻译

### 题目描述 学生宿舍里只有一个淋浴,有很多个学生希望早上洗澡。这就是为什么每天早上宿舍门口有五个人排队的原因。淋浴一打开,第一个人就从队里进入淋浴。一段时间后,第一个人离开淋浴,下一个人进入淋浴。这个过程一直持续到每个人淋浴过。 洗澡需要一些时间,所以排队的学生在这时讲话。学生们成对交谈:第 $2\times i-1$ 个人与第 $2\times i$ 个人交谈。 更详细些,把人数从 $1$ 到 $5$ 编号,让我们假设队列最初看起来是 $23154$(编号 $2$ 的人位于队列的开头),然后,在淋浴开始前,$2$ 和 $3$ 谈话, $1$ 和 $5$ 谈话,$4$ 没有任何人交谈,$2$ 洗澡时,$3$ 和 $1$ 交谈,$5$ 和 $4$ 交谈,$3$ 洗澡时,$1$ 和 $5$ 聊天,$4$ 没有任何人交谈,$1$ 洗澡时,$5$ 和 $4$ 聊天,然后 $5$ 淋浴,$4$ 淋浴。 我们知道如果 $i$ 和 $j$ 交谈,$i$ 的幸福值增加 $g_{i,j}$,$j$ 的幸福值增加 $g_{j,i}$,你的任务是找到这样一排学生最初的顺序,使得所有学生的幸福感和最终达到最大。 ### 输入格式 输入共五行,每行输入五个用空格分隔的整数。第 $i$ 行的第 $j$ 个整数代表 $g_{i,j}$。保证对于所有 $i$ 的 $g_{i,i}=0$。 ### 输出格式 输出共 $1$ 行,输出学生最大的总幸福感. ### 数据范围 对于 $100\%$ 的数据,满足 $0\le g_{i,j}\le10^5$。

题目描述

Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. There is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people in front of the dormitory shower door. As soon as the shower opens, the first person from the line enters the shower. After a while the first person leaves the shower and the next person enters the shower. The process continues until everybody in the line has a shower. Having a shower takes some time, so the students in the line talk as they wait. At each moment of time the students talk in pairs: the $ (2i-1) $ -th man in the line (for the current moment) talks with the $ (2i) $ -th one. Let's look at this process in more detail. Let's number the people from 1 to 5. Let's assume that the line initially looks as 23154 (person number 2 stands at the beginning of the line). Then, before the shower opens, 2 talks with 3, 1 talks with 5, 4 doesn't talk with anyone. Then 2 enters the shower. While 2 has a shower, 3 and 1 talk, 5 and 4 talk too. Then, 3 enters the shower. While 3 has a shower, 1 and 5 talk, 4 doesn't talk to anyone. Then 1 enters the shower and while he is there, 5 and 4 talk. Then 5 enters the shower, and then 4 enters the shower. We know that if students $ i $ and $ j $ talk, then the $ i $ -th student's happiness increases by $ g_{ij} $ and the $ j $ -th student's happiness increases by $ g_{ji} $ . Your task is to find such initial order of students in the line that the total happiness of all students will be maximum in the end. Please note that some pair of students may have a talk several times. In the example above students 1 and 5 talk while they wait for the shower to open and while 3 has a shower.

输入输出格式

输入格式


The input consists of five lines, each line contains five space-separated integers: the $ j $ -th number in the $ i $ -th line shows $ g_{ij} $ ( $ 0<=g_{ij}<=10^{5} $ ). It is guaranteed that $ g_{ii}=0 $ for all $ i $ . Assume that the students are numbered from 1 to 5.

输出格式


Print a single integer — the maximum possible total happiness of the students.

输入输出样例

输入样例 #1

0 0 0 0 9
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
7 0 0 0 0

输出样例 #1

32

输入样例 #2

0 43 21 18 2
3 0 21 11 65
5 2 0 1 4
54 62 12 0 99
87 64 81 33 0

输出样例 #2

620

说明

In the first sample, the optimal arrangement of the line is 23154. In this case, the total happiness equals: $ (g_{23}+g_{32}+g_{15}+g_{51})+(g_{13}+g_{31}+g_{54}+g_{45})+(g_{15}+g_{51})+(g_{54}+g_{45})=32 $ .