看大佬的代码都好复杂(不愧是大佬(orz)
蒟蒻提供一种思路
因为求的是最近的车对吧(qwq)
所以我们可以用一个(while)循环所以没必要去用什么 (for...)
至于这是(div2)的第一题还是比较水的
#include <bits/stdc++.h>
#define rep(i,j,n) for(register int i=j;i<=n;i++)
#define Rep(i,j,n) for(register int i=j;i>=n;i--)
#define low(x) x&(-x)
using namespace std ;
typedef long long LL ;
const int inf = INT_MAX >> 1 ;
inline LL In() { LL res(0) , f(1) ; register char c ;
#define gc c = getchar()
while(isspace(gc)) ; c == '-' ? f = - 1 , gc : 0 ;
while(res = (res << 1) + (res << 3) + (c & 15) , isdigit(gc)) ;
return res * f ;
#undef gc
}
int n , t ;
const int N = 100 + 5 ;
struct node {
int s , d ;
}a[N] ;
inline void Ot() {
n = In() , t = In() ;
rep(i,1,n) a[i].s = In() , a[i].d = In() ;
int tmp = inf ;
int ans = 0 ;
rep(i,1,n) {
int s = a[i].s ;
while(s < t) s += a[i].d ;
if(tmp > (s-t)) tmp = (s-t) , ans = i ;
}
cout << ans << endl ;
}
signed main() {
// freopen("test.in","r",stdin) ;
return Ot() , 0 ;
}