Lucien

Codeforces - 1153A - Serval and Bus
地址https://codeforces.com/contest/1153/problem/A原文地址https:...
扫描右侧二维码阅读全文
15
2019/04

Codeforces - 1153A - Serval and Bus

地址

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;
}
最后修改:2019 年 04 月 15 日 12 : 01 AM
谢谢老板!

发表评论