Problem H. Harmonious Army
时间限制 1000 ms
内存限制 128 MB
Now, Bob is playing an interesting game in which he is a general of a harmonious army. There are $n$ soldiers in this army. Each soldier should be in one of the two occupations, Mage or Warrior. There are $m$ pairs of soldiers having combination ability. There are three kinds of combination ability. If the two soldiers in a pair are both Warriors, the army power would be increased by $a$. If the two soldiers in a pair are both Mages, the army power would be increased by $c$. Otherwise the army power would be increased by $b$, and $b = a / 4 + c / 3$, guaranteed that $4 | a$ and $3 | c$. Your task is to output the maximum power Bob can increase by arranging the soldiers' occupations.
Note that the symbol $a | b$ means that $a$ divides $b$, e.g. , $3|12$ and $8|24$.
输入数据
输出数据
For each test case, output one line containing the maximum power Bob can increase by arranging the soldiers' occupations.
样例输入
复制
3 2
1 2 8 3 3
2 3 4 3 6
样例输出
$ Mathjax font initiator $