#P2090. Stone Game

Stone Game

题目描述

点击这里查看pdf

MianKing has nn piles of stones and each pile has at most 33 stones, now he wants to merge all of these stones into one pile.

In order to achieve his goal, each time MianKing can choose two piles of stones and merge them into a new pile, and the number of stones in the new pile is the sum of these two piles.

Because it takes manpower to move stones, in each operation if the numbers of these two piles of stones are xx and yy respectively, MianKing should pay (x mod 3)(y mod 3)(x~mod~3)(y~mod~3) coins for it.

Now MianKing wants to know the minimum amount of coins he need to pay to merge all of these stones into one pile.

输入格式

The first line has 33 integers a1,a2,a3a_1,a_2,a_3. And aia_i denotes the number of piles which have ii stones.

0leqaileq1090\\leq a_i\\leq 10^9

sumi=13ai>0\\sum_{i=1}^{3}a_i>0

输出格式

Output one integer: the minimum amount of coins MianKing need to pay for his goal.

样例

1 1 1 

2 

99 66 55 

165 

提示

Form 2020ICPC济南站