当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6598:Harmonious Army

题目描述
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$.
输入解释
There are multiple test cases.

Each case starts with a line containing two positive integers $n(n \leq 500)$ and $m(m \leq 10^4)$.

In the following $m$ lines, each line contains five positive integers $u, \; v, \; a, \; b, \; c$ $(1 \leq u, v \leq n, u \neq v, 1 \leq a, c \leq 4 \times 10 ^6, b = a / 4 + c / 3)$, denoting soldiers $u$ and $v$ have combination ability, guaranteed that the pair $(u,v)$ would not appear more than once.

It is guaranteed that the sum of $n$ in all test cases is no larger than $5 \times 10^3$, and the sum of $m$ in all test cases is no larger than $5 \times 10^4$.
输出解释
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
输出样例
12
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6598

最后修改于 2020-10-25T23:32:41+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)