CF91E.Igloo Skyscraper

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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

There are nn walruses taking part in the contest. Each walrus is given a unique number from 11 to nn . After start each walrus begins to build his own igloo skyscraper. Initially, at the moment of time equal to 00 , the height of the skyscraper ii -th walrus is equal to aia_{i} . Each minute the ii -th walrus finishes building bib_{i} floors.

The journalists that are reporting from the spot where the Olympiad is taking place, make qq queries to the organizers. Each query is characterized by a group of three numbers lil_{i} , rir_{i} , tit_{i} . The organizers respond to each query with a number xx , such that:

1. Number xx lies on the interval from lil_{i} to rir_{i} inclusive ( li<=x<=ril_{i}<=x<=r_{i} ).

2. The skyscraper of the walrus number xx possesses the maximum height among the skyscrapers of all walruses from the interval [li,ri][l_{i},r_{i}] at the moment of time tit_{i} .

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

输入格式

The first line contains numbers nn and qq ( 1<=n,q<=1051<=n,q<=10^{5} ). Next nn lines contain pairs of numbers aia_{i} , bib_{i} ( 1<=ai,bi<=1091<=a_{i},b_{i}<=10^{9} ). Then follow qq queries i the following format lil_{i} , rir_{i} , tit_{i} , one per each line ( 1<=li<=ri<=n1<=l_{i}<=r_{i}<=n , 0<=ti<=1060<=t_{i}<=10^{6} ). All input numbers are integers.

输出格式

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

输入输出样例

  • 输入#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
    
首页