Karan goes to McDonalds
All submissions for this problem are available.Karan is at McDonalds presently. There are total $N$ counters where he can place his order. There are $A_i$ people already present at each counter to get their order. Each counter gives the order to one person in **one** minute. Initially, Karan stands in front of the first counter. After each minute, if he doesn't get his order, he moves on to the next counter to get his order. If he is at counter $1$, he will move to $2$. If at $2$, he will move to $3$. If he is at the last counter, he will move to $1$ again and so on. Find the counter number at which he will get his order. ###Input: - The first line consists of $N$, denoting the no. of counters. - Next line contains $N$ space separated integers denoting the no. of people already standing in front of the $ith$ counter. $(1 <= i <= n)$ ###Output: - Print a single integer denoting the counter number that Karan will get his order from. ###Constraints - $1 \leq N \leq 10^5$ - $1 \leq A_i \leq 10^9$ ###Subtasks - 30 points : - $1 \leq N \leq 10$ - $1 \leq A_i \leq 10^2$ - 70 points : Original Constraints ###Sample Input: 4 2 3 2 0 ###Sample Output: 3 ###EXPLANATION: Karan at Counter 1: $[2, 3, 2, 0]$ Karan at Counter 2: $[1, 2, 1, 0]$ Karan at Counter 3: $[0, 1, 0, 0]$ So, when Karan is at Counter 3, he got zero people before him. Hence, he will get his order at Counter 3.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.