CF450A Jzzhu and Children
题目描述
`Jzzhu`给学校里的$n$个孩子发糖果,编号从$1$到$n$排成一队,第$i$个孩子想得到至少$a_i$个糖果。
`Jzzhu`的操作如下:
- 给队首的孩子$m$个糖果
- 如果这个孩子已经得到满足,他就会回家,否则他会到队尾。
- 在队列非空时重复上述两个操作
在满足上述条件的情况下,求出最后回家的孩子的编号
输入格式
第一行两个整数$n,m(1\leq n,m\leq100)$,第二行$n$个整数$a_1,a_2,\cdots,a_n(\forall a_i\in[1,100])$
输出格式
输出一个整数表示最后回家的孩子的编号
说明/提示
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.