A12484 | Serval and Bus
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor little boy is to wait for a bus on this rainy day. Under such circumstances, the poor boy will use the first bus he sees no matter where it goes. If several buses come at the same time, he will choose one randomly.
Serval will go to the bus station at time $t$ , and there are $n$ bus routes which stop at this station. For the $i$ -th bus route, the first bus arrives at time $s_i$ minutes, and each bus of this route comes $d_i$ minutes later than the previous one.
As Serval's best friend, you wonder which bus route will he get on. If several buses arrive at the same time, you can print any of them.
Serval will go to the bus station at time $t$ , and there are $n$ bus routes which stop at this station. For the $i$ -th bus route, the first bus arrives at time $s_i$ minutes, and each bus of this route comes $d_i$ minutes later than the previous one.
As Serval's best friend, you wonder which bus route will he get on. If several buses arrive at the same time, you can print any of them.
输入格式
The first line contains two space-separated integers $n$ and $t$ ( $1\leq n\leq 100$ , $1\leq t\leq 10^5$ ) — the number of bus routes and the time Serval goes to the station.
Each of the next $n$ lines contains two space-separated integers $s_i$ and $d_i$ ( $1\leq s_i,d_i\leq 10^5$ ) — the time when the first bus of this route arrives and the interval between two buses of this route.
Each of the next $n$ lines contains two space-separated integers $s_i$ and $d_i$ ( $1\leq s_i,d_i\leq 10^5$ ) — the time when the first bus of this route arrives and the interval between two buses of this route.
输出格式
Print one number — what bus route Serval will use. If there are several possible answers, you can print any of them.
输入输出样例
输入 #1
2 2 6 4 9 5
输出 #1
1
输入 #2
5 5 3 3 2 5 5 6 4 9 6 1
输出 #2
3
输入 #3
3 7 2 2 2 3 2 4
输出 #3
1
In the first example, the first bus of the first route arrives at time $6$ , and the first bus of the second route arrives at time $9$ , so the first route is the answer.
In the second example, a bus of the third route arrives at time $5$ , so it is the answer.
In the third example, buses of the first route come at times $2$ , $4$ , $6$ , $8$ , and so fourth, buses of the second route come at times $2$ , $5$ , $8$ , and so fourth and buses of the third route come at times $2$ , $6$ , $10$ , and so on, so $1$ and $2$ are both acceptable answers while $3$ is not.
In the second example, a bus of the third route arrives at time $5$ , so it is the answer.
In the third example, buses of the first route come at times $2$ , $4$ , $6$ , $8$ , and so fourth, buses of the second route come at times $2$ , $5$ , $8$ , and so fourth and buses of the third route come at times $2$ , $6$ , $10$ , and so on, so $1$ and $2$ are both acceptable answers while $3$ is not.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted