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

建议使用的浏览器:

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

6824:Exam

题目描述
You have to take $n$ exams, the exam $i$ was held in two periods of time, [$a$, $a$ + $at$] and [$b$, $b$ + $bt$] and you can take any one of the two periods to pass exam $i$. But note that you cannot take two different exams at the same time. For example, it is impossible to take the first exam at $[3,5]$ and take the second exam at $[5,8]$. \textbf{And note that for one exam}, the two periods of time may intersect, that is, $[a,\ a+at] \cap [b,\ b+bt] \ne \emptyset$ is also possible. Now, you want to pass all the $n$ exams as soon as possible. Print the earlist time when the last exam was finished if you can pass all the $n$ exams or print $-1$ if you can not pass all the exams.
输入解释
The first line contains a single integer $T$ denoting the number of test cases. For each test case, the first line contains a single integer $n$ ($1\leq n \leq 25000$). The next $n$ lines contain four integers each: $a$, $at$, $b$, $bt$ ($0\leq a,\ at,\ b,\ bt \leq 10^{9}$ and $\sum n \le 10^5$)
输出解释
For each test case, output the only line containing just one integer denoting the answer if there would be, or $-1$ otherwise.
输入样例
4
2
1 5 5 10
1 3 7 2
3
5 0 13 0
1 0 5 0
1 0 7 0
3
10 7 40 1
40 5 80 15
10 20 80 6
3
1 0 2 0
1 0 2 0
1 0 2 0
输出样例
9
7
86
-1
来自杭电HDUOJ的附加信息
Recommend IceyWang

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

源链接: HDU-6824

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

共提交 0

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