SOLVE

LATER

KillCode's Wish

Problem

Editorial

Analytics

KillCode is very thrilled to have won unlimited ladoos in a programming competition . But being a generous programmer he decided to give away all his ladoos to small children. Now there are n children standing in a queue where **a[i]** denotes the hunger of i**th** child. KillCode can give maximum of **M** ladoos to a child at a time. Now there are 2 conditions :

1- If a child gets equal to or more ladoos than his hunger , then he will return back to his home.

2- If a child gets less ladoos , he will take **m** ladoos and will move to last in the queue to get his turn again.

**Constraints :**

1<=n,m<=10000

1<=a[i]<=10000000

**Input:**

The first line contain integer t denoting the test cases , next t line follows : Now you will be given N,M . Next line will contain n space separated integers .

**Output:**

Output the index of child who will remain last in the queue.

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Visual Basic

Initializing Code Editor...

{"8932e4c": "/pagelets/recommended-problems/algorithm/killcodes-wish-2/", "63a820b": "/pagelets/problems-hint/algorithm/killcodes-wish-2/", "d469146": "/pagelets/show-submission/algorithm/killcodes-wish-2/", "0d63def": "/pagelets/problem-author-tester/algorithm/killcodes-wish-2/", "a825190": "/pagelets/suggested-problems/algorithm/killcodes-wish-2/"}

realtime.hackerearth.com

80

1fe0bf28d3387201cd5c01df9b10ba30623b0f39

58a29e5cae2309f04b28

/realtime/pusher/auth/