CF1153A.Serval and Bus
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 si minutes, and each bus of this route comes di 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.
正在下大雨。但今天是刚满3岁的Serval第一天上幼儿园。不幸的是,他家离幼儿园很远,而他的父亲太忙,无法开车送他去。这个可怜的小男孩在这样 rainy 的日子里唯一的选择就是在公交站等公交车。在这种情况下,这个可怜的小男孩会乘坐他看到的第一辆公交车,无论它开往何处。如果有多辆公交车同时到达,他将随机选择其中一辆。
Serval 将于时间 t 到达公交站,该车站共有 n 条公交线路停靠。对于第 i 条公交线路,第一班车于 si 分钟时到达,此后该线路的每辆公交车均比前一辆晚 di 分钟到达。
作为 Serval 最好的朋友,你想知道他将乘坐哪条公交线路。如果有多辆公交车同时到达,你可以输出其中任意一条。
输入格式
The first line contains two space-separated integers n and t (1≤n≤100, 1≤t≤105) — the number of bus routes and the time Serval goes to the station.
Each of the next n lines contains two space-separated integers si and di (1≤si,di≤105) — the time when the first bus of this route arrives and the interval between two buses of this route.
第一行包含两个用空格分隔的整数 n 和 t(1≤n≤100,1≤t≤105)—— 分别表示公交线路的数量以及 Serval 到达车站的时间。
接下来的 n 行中,每行包含两个用空格分隔的整数 si 和 di(1≤si,di≤105)—— 分别表示该线路首班公交车的到达时间,以及该线路两班公交车之间的发车间隔。
输出格式
Print one number — what bus route Serval will use. If there are several possible answers, you can print any of them.
输出一个数字——Serval 将乘坐的公交线路编号。如果存在多个可能的答案,输出其中任意一个即可。
输入输出样例
输入#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.
在第一个例子中,第一条线路的首班公交车在时刻 6 到达,第二条线路的首班公交车在时刻 9 到达,因此第一条线路是答案。
在第二个例子中,第三条线路的一辆公交车在时刻 5 到达,因此它是答案。
在第三个例子中,第一条线路的公交车到达时刻为 2、4、6、8,……;第二条线路的公交车到达时刻为 2、5、8,……;第三条线路的公交车到达时刻为 2、6、10,……。因此,1 和 2 均为可接受的答案,而 3 不可接受。
输入解题思路,AI测评打分。不知道怎么写?