[CodeForce 450A] Jzzhu and Children

题目链接:http://codeforces.com/problemset/problem/450/A

/*
 * 计算一个人要是拿足够离开需要排多少次队,选排的次数多的那个人,如果两个人排的次数相同,那么要取后者;
 */

#include <cstdio>

using namespace std;

int main() {
    int n, m;
    int a, b, j, maxn;
    while (scanf("%d%d", &n, &m) != EOF) {
        maxn = -1;
        for (int i = 1; i <= n; i++) {
            scanf("%d", &a);
            b = a / m;
            if (a % m > 0) {
                b++;
            }
            if (maxn <= b) {
                maxn = b;
                j = i;
            }
        }
        printf("%d\n", j);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/youpeng/p/10745039.html