A8258 | Igloo Skyscraper
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains numbers $n$ and $q$ ( $1<=n,q<=10^{5}$ ). Next $n$ lines contain pairs of numbers $a_{i}$ , $b_{i}$ ( $1<=a_{i},b_{i}<=10^{9}$ ). 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}<=10^{6}$ ). All input numbers are integers.
输出格式
For each journalists' query print the number of the walrus $x$ 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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted