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

建议使用的浏览器:

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

7172:Taxi

题目描述
There are $n$ towns in Byteland, labeled by $1,2,\dots,n$. The $i$-th town's location is $(x_i,y_i)$. Little Q got a taxi VIP card, he can use the VIP card to cut down the taxi fare. Formally, assume Little Q is at $(x',y')$, if he calls a taxi to drive him to the $k$-th town, the VIP card will reduce $\min(|x'-x_k|+|y'-y_k|,w_k)$ dollars.

Little Q wants to make full use of his VIP card. He will give you $q$ queries, in each query you will be given his location, and you need to choose a town such that the VIP card will reduce the most taxi fare.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 100$), the number of test cases. For each test case:

The first line contains two integers $n$ and $q$ ($1 \leq n,q \leq 100\,000$), denoting the number of towns and the number of queries.

Each of the following $n$ lines contains three integers $x_i$, $y_i$ and $w_i$ ($1 \leq x_i,y_i,w_i \leq 10^9$), describing a town.

Each of the following $q$ lines contains two integers $x'$ and $y'$ ($1 \leq x',y' \leq 10^9$), describing a query.

It is guaranteed that the sum of all $n$ is at most $500\,000$, and the sum of all $q$ is at most $500\,000$.
输出解释
For each query, print a single line containing an integer, denoting the maximum possible reduced taxi fare.
输入样例
1
3 4
1 5 7
5 1 6
2 3 9
1 5
2 2
4 3
10 10
输出样例
6
4
5
9

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

源链接: HDU-7172

最后修改于 2022-09-15T06:17:10+00:00 由爬虫自动更新

共提交 0

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