Codeforces - 1153A - Serval and Bus
Codeforces - 1153A - Serval and Bus
地址
https://codeforces.com/contest/1153/problem/A
原文地址
https://www.lucien.ink/archives/413
代码
https://pasteme.cn/6247
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## include <bits/stdc++.h>
int main() {
int n, m, min = 0x3f3f3f3f, ans, buf;
scanf("%d%d", &n, &m);
for (int i = 1, a, d; i <= n; i++) {
scanf("%d%d", &a, &d);
if (a >= m) buf = a - m;
else {
buf = d - (m - a) % d;
if (buf >= d) buf -= d;
}
if (buf < min) min = buf, ans = i;
}
printf("%d\n", ans);
return 0;
}
This post is licensed under CC BY 4.0 by the author.