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

建议使用的浏览器:

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

6811:Joyful Party

题目描述
It is Zhang3's birthday! Zhang3 is going to hold a birthday party.

Zhang3 prepared $n$ puzzles for the party, labeled $1, 2, \ldots, n$. She invited $m$ friends to solve the puzzles. Each puzzle should be solved by exactly one friend, and each friend should solve at least one puzzle. The puzzles must be solved in some order, which means no two puzzles can be solved simultaneously.

As some puzzles are similar, it may be possible to solve a puzzle by imitating another one. This makes the puzzle solver very happy and produces some joy-value for the party. Specifically, there are some methods to solve a puzzle by imitating. Each of the methods is of the form $(X, L, R, C)$, which means when someone is going to solve puzzle $X$, he can choose another puzzle $Y \in [L, R]$, as long as he has solved puzzle $Y$ before, then use the method to solve puzzle $X$ by imitating puzzle $Y$, producing $C$ joy-value. Only one imitation can be done while solving a certain puzzle, i.e. only one method and one solved puzzle can be chosen to perform the imitation, even if there are multiple methods and solved puzzles meeting the requirements. Imitating nothing is also allowed, producing no joy-value.

Zhang3 wants to maximize the total joy-value. Please help her schedule the party (i.e. decide who to solve each puzzle, the order of solving, and the imitations) so that the sum of joy-value produced by imitations is maximized.
输入解释
The first line of the input gives the number of test cases, $T \; (1 \le T \le 2)$. $T$ test cases follow.

For each test case, the first line contains three integers $n, m, k \; (1 \le m \le n \le 10^5, \; k \le 2 \times 10^5)$, the number of puzzles, the number of friends and the number of methods.

Then $k$ lines follow, the $i ^ \mathrm{th}$ of which contains four integers $X_i, L_i, R_i, C_i \; (1 \le L_i \le R_i \le n, \; 0 \le C_i \le 10^9)$, representing the $i ^ \mathrm{th}$ method is $(X_i, L_i, R_i, C_i)$.
输出解释
For each test case, print a line with an integer, representing the maximized total joy-value.
输入样例
1
3 1 3
1 1 3 600000
1 3 3 666666
3 1 1 173768
输出样例
773768
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6811

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

共提交 0

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