At The Supermarket
Today, Bob is at the supermarket. Done getting his groceries, he is now ready to pay and lines up to checkout.
There are \(N\) checkout lanes numbered from \(1\) to \(N\) and currently \(M\) grocery goers in front of Bob.
Every time a checkout lane opens, the person at the front of the line immediately goes there to checkout, and person \(i\) (\(1 \le i \le M\)) will need \(s_i\) seconds to finish checking out. If more than one checkout lane is avaiable, the person chooses to join the checkout lane with the smallest number.
Please tell Bob the number of the checkout lane that he will end up at.
Input Specification
The first line contains two integers \(N\) and \(M\) (\(1 ≤ N ≤ 100, 0 ≤ M ≤ 2000\)).
The second line contains \(M\) integers \(S_1, S_2, …, S_M\) (\(1 ≤ S_i ≤ 100\)), where \(S_i\) is the service time of the person \(i\).
Output Specification
Print one integer: the number of the checkout lane that Bob ends up at.
Sample Input
2 3
10 5 6
Sample Output
1
Initially, checkout \(1\) and \(2\) are both open. Customer \(1\) goes to checkout \(1\) and customer \(2\) goes to checkout \(2\).
After \(5\) seconds, customer \(2\) finishes, and checkout lane \(2\) opens. Customer \(3\) goes to checkout lane \(2\). Customer \(1\) still has \(5\) seconds left.
After another \(5\) seconds, customer \(1\) finishes, and checkout lane \(1\) opens. Customer \(3\) still has \(1\) second left.
Since it is now open, Bob endss up in checkout lane \(1\).
Comments