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

建议使用的浏览器:

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

6126:Give out candies

题目描述
There are $n$ children numbered $1$ to $n$, and HazelFan's task is to give out candies to the children. Each children must be given at least $1$ and at most $m$ candies. The children raised $k$ pieces of requirements, and every piece includes three integers $x,y,z$, means that the number of candies given to the child numbered $x$, subtract the number of candies given to the child number $y$, the result should not be more than $z$. Besides, if the child numbered $i$ is given $j$ candies, he or she will get $w_{i,j}$ satisfaction score, now you need to help HazelFan maximize the sum of the satisfaction scores of these children.
输入解释
The first line contains a positive integer $T(1\leq T\leq5)$, denoting the number of test cases.
For each test case:
The first line contain three positive integers $n,m,k(1\leq n,m\leq50,1\leq k\leq150)$.
The next $n$ lines, the $i$th line contains $m$ positive integers, the $j$th integer denotes $w_{i,j}$.
The next $k$ lines, each line contains three integers $x,y,z(1\leq x,y\leq n,\mid z\mid<233)$, denoting a piece of requirement.
输出解释
For each test case:
A single line contains a nonnegative integer, denoting the answer. Particularly, if there is no way to give out candies, print -1.
输入样例
2
2 1 1
1
1
1 2 1
3 3 2
1 2 3
2 3 1
3 1 2
1 2 0
2 3 0
输出样例
2
7
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6126

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

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 524288/524288K(Java/Others)