codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1153A.md (2298B)


      1 Source: https://codeforces.com/problemset/problem/1153/A
      2 
      3 A. Serval and Bus
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 Input
     28 
     29 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.
     30 
     31 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.
     32 
     33 Output
     34 
     35 Print one number — what bus route Serval will use. If there are several possible answers, you can print any of them.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 2 2
     43 6 4
     44 9 5
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 1
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 5 5
     57 3 3
     58 2 5
     59 5 6
     60 4 9
     61 6 1
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 3
     68 ```
     69 
     70 Input
     71 
     72 ```
     73 3 7
     74 2 2
     75 2 3
     76 2 4
     77 ```
     78 
     79 Output
     80 
     81 ```
     82 1
     83 ```
     84 
     85 Note
     86 
     87 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.
     88 
     89 In the second example, a bus of the third route arrives at time $5$, so it is the answer.
     90 
     91 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.