CF91E.Igloo Skyscraper

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building!

There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. After start each walrus begins to build his own igloo skyscraper. Initially, at the moment of time equal to 0, the height of the skyscraper i-th walrus is equal to a__i. Each minute the i-th walrus finishes building b__i floors.

The journalists that are reporting from the spot where the Olympiad is taking place, make q queries to the organizers. Each query is characterized by a group of three numbers l__i, r__i, t__i. The organizers respond to each query with a number x, such that:

1. Number x lies on the interval from l__i to r__i inclusive (l__i ≤ x ≤ r__i).

2. The skyscraper of the walrus number x possesses the maximum height among the skyscrapers of all walruses from the interval [l__i, r__i] at the moment of time t__i.

For each journalists' query print the number of the walrus x that meets the above-given criteria. If there are several possible answers, print any of them.

今天,北极举办了一场名为“玩具冰屋摩天大楼建造”的奥林匹克竞赛!

共有 nn 头海象参加本次比赛。每头海象被赋予一个从 11 到 nn 的唯一编号。比赛开始后,每头海象立即开始建造自己的冰屋摩天大楼。初始时刻(即时间为 00 时),第 ii 头海象所建摩天大楼的高度为 aia_i。此后,每分钟第 ii 头海象可完工 bib_i 层。

在现场报道本次奥林匹克竞赛的记者们向主办方提出了 qq 个询问。每个询问由三个整数 lil_i、rir_i、tit_i 构成。主办方对每个询问的回答是一个整数 xx,满足以下条件:

  1. 数 xx 落在区间 [li,ri][l_i, r_i] 内(即 li≤x≤ril_i \le x \le r_i);

  2. 在时刻 tit_i,第 xx 号海象所建摩天大楼的高度,在所有编号属于区间 [li,ri][l_i, r_i] 的海象所建摩天大楼中达到最大值。

对每个记者的询问,请输出满足上述条件的海象编号 xx。若存在多个可能的答案,输出其中任意一个即可。

输入格式

The first line contains numbers n and q (1 ≤ n, q ≤ 105). Next n lines contain pairs of numbers a__i, b__i (1 ≤ a__i, b__i ≤ 109). Then follow q queries i the following format l__i, r__i, t__i, one per each line (1 ≤ l__i ≤ r__i ≤ n, 0 ≤ t__i ≤ 106). All input numbers are integers.

第一行包含两个整数 nn 和 qq(1 ≤ n, q ≤ 1051 \leq n, q \leq 10^5)。接下来的 nn 行每行包含一对整数 aia_i、bib_i(1 ≤ ai, bi ≤ 1091 \leq a_i, b_i \leq 10^9)。随后是 qq 个查询,每个查询格式为 lil_i、rir_i、tit_i,每行一个(1 ≤ li ≤ ri ≤ n1 \leq l_i \leq r_i \leq n,0 ≤ ti ≤ 1060 \leq t_i \leq 10^6)。所有输入数据均为整数。

输出格式

For each journalists' query print the number of the walrus x that meets the criteria, given in the statement. Print one number per line.

对于每位记者的查询,请输出满足题目中所述条件的海象 x 的编号。每行输出一个数字。

输入输出样例

  • 输入#1

    5 4
    4 1
    3 5
    6 2
    3 5
    6 5
    1 5 2
    1 3 5
    1 1 0
    1 5 0

    输出#1

    5
    2
    1
    5
  • 输入#2

    5 4
    6 1
    5 1
    2 5
    4 3
    6 1
    2 4 1
    3 4 5
    1 4 5
    1 2 0

    输出#2

    3
    3
    3
    1

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

首页