AT_abc463_c.Tallest at the Moment
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Currently, there are N Takahashi in a conference room. The i-th (1≤i≤N) Takahashi has a height of Hi and will leave the room Li minutes from now. Once a Takahashi leaves the room, he never returns.
You are given Q queries, so answer them in order. For the i-th (1≤i≤Q) query, you are given an integer Ti, so find the maximum height among the Takahashi who are in the room Ti+21 minutes from now. Under the constraints of this problem, it is guaranteed that at least one Takahashi will be in the room Ti+21 minutes from now.
目前,会议室内有 N 个高桥。第 i 个(1≤i≤N)高桥身高为 Hi,将在 Li 分钟后离开房间。一旦某个高桥离开房间,他就不会再返回。
你将收到 Q 个查询,请按顺序回答它们。对于第 i 个(1≤i≤Q)个查询,给定一个整数 Ti,请找出在 Ti+21 分钟后仍在房间内的所有高桥中的最大身高。在本题的约束条件下,保证在 Ti+21 分钟后,房间内至少还剩一名高桥。
输入格式
The input is given from Standard Input in the following format:
N
H1 L1
H2 L2
⋮
HN LN
Q
T1 T2 … TQ
输入从标准输入中按以下格式给出:
N
H1 L1
H2 L2
⋮
HN LN
Q
T1 T2 … TQ
输出格式
Output Q lines. The i-th line (1≤i≤Q) should contain the answer to the i-th query.
输出 Q 行。第 i 行(1≤i≤Q)应包含第 i 个查询的答案。
输入输出样例
输入#1
4 31 4 26 5 3 5 15 9 4 3 4 5 6
输出#1
31 26 15 15
输入#2
10 587 138 772 155 755 404 519 408 529 432 169 586 114 632 249 656 329 972 299 984 14 443 801 824 276 399 314 300 510 311 580 498 930 359 5
输出#2
329 329 329 755 755 755 755 329 755 329 329 329 755 772
说明/提示
Sample 1 Explanation:
3+21 minutes from now, all Takahashi currently in the room are still there. Thus, the answer to the first query is 31, the maximum of {31,26,3,15}.
5+21 minutes from now, only the fourth Takahashi is in the room. Thus, the answer to the third query is 15, the maximum of {15}.
Constraints
- 1≤N≤3×105
- 1≤Hi≤109 (1≤i≤N)
- 1≤L1≤L2≤⋯≤LN≤109
- 1≤Q≤3×105
- 0≤Ti<LN (1≤i≤Q)
- All input values are integers.
样例 1 解释:
从现在起 3+21 分钟后,房间内所有当前存在的高桥仍留在房间中。因此,第一个查询的答案为 31,即集合 {31,26,3,15} 中的最大值。
从现在起 5+21 分钟后,房间内仅剩第四位高桥。因此,第三个查询的答案为 15,即集合 {15} 中的最大值。
约束条件
- 1≤N≤3×105
- 1≤Hi≤109 (1≤i≤N)
- 1≤L1≤L2≤⋯≤LN≤109
- 1≤Q≤3×105
- 0≤Ti<LN (1≤i≤Q)
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?