Codeforces - 1153A - Serval and Bus

版权声明:文章来自 https://www.lucien.ink,转载请注明文章出处 https://blog.csdn.net/xs18952904/article/details/89304533

地址

https://codeforces.com/contest/1153/problem/A

原文地址

https://www.lucien.ink/archives/413

代码

https://pasteme.cn/6247

#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;
}
展开阅读全文

没有更多推荐了,返回首页