CF450A.Jzzhu and Children

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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

  1. Give mm 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,mn,m (1<=n<=100; 1<=m<=100)(1<=n<=100; 1<=m<=100) . The second line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} (1<=ai<=100)(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
    

说明/提示

Let's consider the first sample.

Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.

Child 4 is the last one who goes home.

首页