Problem Statement | |||||||||||||
Rabbit Hanako has N boxes of carrots numbered 0 through N-1. The i-th box contains carrots[i] carrots.
She decides to eat K carrots from these boxes. She will eat the carrots one at a time, each time choosing a carrot from the box with the greatest number of carrots. If there are multiple such boxes, she will choose the lowest numbered box among them. Return the number of the box from which she will eat her last carrot. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | carrots will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of carrots will be between 1 and 100, inclusive. | ||||||||||||
- | K will be between 1 and the sum of all elements of carrots, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|