题库练习 Jzzhu and Children
← 上一题 下一题 →

A9483 | Jzzhu and Children

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

There are $n$ children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from $1$ to $n$ . The $i$ -th child wants to get at least $a_{i}$ candies.

Jzzhu asks children to line up. Initially, the $i$ -th child stands at the $i$ -th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:

1. Give $m$ candies to the first child of the line.
2. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.
3. Repeat the first two steps while the line is not empty.

Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?

输入格式

The first line contains two integers $n,m$ $(1<=n<=100; 1<=m<=100)$ . The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ $(1<=a_{i}<=100)$ .

输出格式

Output a single integer, representing the number of the last child.

输入输出样例

输入 #1
5 2
1 3 1 4 2
输出 #1
4
输入 #2
6 4
1 1 2 2 3 3
输出 #2
6
C++ 编辑器
输入
输出