AT_abc463_c.Tallest at the Moment

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Currently, there are NN Takahashi in a conference room. The ii-th (1≤i≤N)(1\le i\le N) Takahashi has a height of HiH _ i and will leave the room LiL _ i minutes from now. Once a Takahashi leaves the room, he never returns.

You are given QQ queries, so answer them in order. For the ii-th (1≤i≤Q)(1\le i\le Q) query, you are given an integer TiT _ i, so find the maximum height among the Takahashi who are in the room Ti+12T _ i+\dfrac12 minutes from now. Under the constraints of this problem, it is guaranteed that at least one Takahashi will be in the room Ti+12T _ i+\dfrac12 minutes from now.

目前,会议室内有 NN 个高桥。第 ii 个(1≤i≤N1\le i\le N)高桥身高为 HiH _ i,将在 LiL _ i 分钟后离开房间。一旦某个高桥离开房间,他就不会再返回。

你将收到 QQ 个查询,请按顺序回答它们。对于第 ii 个(1≤i≤Q1\le i\le Q)个查询,给定一个整数 TiT _ i,请找出在 Ti+12T _ i+\dfrac12 分钟后仍在房间内的所有高桥中的最大身高。在本题的约束条件下,保证在 Ti+12T _ i+\dfrac12 分钟后,房间内至少还剩一名高桥。

输入格式

The input is given from Standard Input in the following format:

NN
H1H _ 1 L1L _ 1
H2H _ 2 L2L _ 2
⋮\vdots
HNH _ N LNL _ N
QQ
T1T _ 1 T2T _ 2 …\ldots TQT _ Q

输入从标准输入中按以下格式给出:

NN
H1H _ 1 L1L _ 1
H2H _ 2 L2L _ 2
⋮\vdots
HNH _ N LNL _ N
QQ
T1T _ 1 T2T _ 2 …\ldots TQT _ Q

输出格式

Output QQ lines. The ii-th line (1≤i≤Q)(1\le i\le Q) should contain the answer to the ii-th query.

输出 QQ 行。第 ii 行(1≤i≤Q1\le i\le Q)应包含第 ii 个查询的答案。

输入输出样例

  • 输入#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+123+\dfrac12 minutes from now, all Takahashi currently in the room are still there. Thus, the answer to the first query is 3131, the maximum of {31,26,3,15}\lbrace31,26,3,15\rbrace.

5+125+\dfrac12 minutes from now, only the fourth Takahashi is in the room. Thus, the answer to the third query is 1515, the maximum of {15}\lbrace15\rbrace.

Constraints

  • 1≤N≤3×1051\le N\le3\times10 ^ 5
  • 1≤Hi≤109 (1≤i≤N)1\le H _ i\le10 ^ 9\ (1\le i\le N)
  • 1≤L1≤L2≤⋯≤LN≤1091\le L _ 1\le L _ 2\le\cdots\le L _ N\le10 ^ 9
  • 1≤Q≤3×1051\le Q\le3\times10 ^ 5
  • 0≤Ti<LN (1≤i≤Q)0\le T _ i\lt L _ N\ (1\le i\le Q)
  • All input values are integers.

样例 1 解释:
从现在起 3+123+\dfrac12 分钟后,房间内所有当前存在的高桥仍留在房间中。因此,第一个查询的答案为 3131,即集合 {31,26,3,15}\lbrace31,26,3,15\rbrace 中的最大值。

从现在起 5+125+\dfrac12 分钟后,房间内仅剩第四位高桥。因此,第三个查询的答案为 1515,即集合 {15}\lbrace15\rbrace 中的最大值。

约束条件

  • 1≤N≤3×1051\le N\le3\times10 ^ 5
  • 1≤Hi≤109 (1≤i≤N)1\le H _ i\le10 ^ 9\ (1\le i\le N)
  • 1≤L1≤L2≤⋯≤LN≤1091\le L _ 1\le L _ 2\le\cdots\le L _ N\le10 ^ 9
  • 1≤Q≤3×1051\le Q\le3\times10 ^ 5
  • 0≤Ti<LN (1≤i≤Q)0\le T _ i\lt L _ N\ (1\le i\le Q)
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页