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

建议使用的浏览器:

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

5854:K-th value

题目描述
There is a country with N cities.

These all cities are connected with roads and have no cycles.

Consider all simple paths whose lengths are between L and R (both inclusive).

Your task is to find the path that minimizes the k-th value of the path among them.

The k-th value of a simple path is “floor(length of path / k) + 1”-th value of the sorted length list of all roads in the path.
输入解释
The first line contains a single integer T representing the number of test cases($1\leq T\leq 100$)
Sum of all $N\leq 700000$
The first line of each test case contains a single integer N.
Each of the following N – 1 lines contains 3 integers which represents two cities of the road and the length of the road.
Next lines contains 3 integers k, L, R.

$1\leq N \leq 10^5$
$1\leq a_i \leq 10^9$
$1 \leq L \leq R \leq 50$
$1<k<50$
输出解释
Output the minimum k-th value of all simple paths whose length is between L and R.

If no such path exists output -1.
输入样例
1
5
1 2 1
2 3 2
3 4 3
4 5 4
2 3 4 
输出样例
2
来自杭电HDUOJ的附加信息
Author 金策工业综合大学(DPRK)
Recommend wange2014

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

源链接: HDU-5854

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

共提交 0

通过率 --%
时间上限 内存上限
30000/15000MS(Java/Others) 65536/65536K(Java/Others)