Milly and Chocolates again
Milly and Pranjul are playing a game in which Pranjul will give an index of a chocolate. Then, Milly has to tell him the box number in which that chocolate is in. There are N such boxes and C_{i} chocolates are there in i^{th} the box. Description of index is given below :
Suppose there are A_{1}, A_{2} … A_{N} chocolates in 1^{st}, 2^{nd}… N^{th} boxes respectively. So, indexing of chocolates in 1^{st} box will be from 1 to A_{1}, similarly in 2^{nd} box indexing will be A_{1} + 1 to A_{2} … and indexing in N^{th} box will be from A_{N-1} + 1 to A_{N}.
Milly is blind folded so she can’t see the boxes. You are required to help her.
Input
- First line will contain N (No. of boxes). Next line will contain N space separated integers denoting C_{i}, the number of chocolates in i^{th} box.
- Next line will contain Q (No. of times Pranjul will ask her). Then each next Q lines will contain the asked index I.
Output
- For every query, print in a new line : the box number in which that index of chocolate is in.
Constraints
- 1 ≤ N, Q ≤ 10^{5}
- 1 ≤ C_{i} ≤ 10
- 1 ≤ ∑ C_{i} ≤ 10^{6}
- 1 ≤ I ≤ ∑ C_{i}
Explanation
First Box will have the indexes : 1, 2
Second Box will have the indexes : 3, 4, 5
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