All Tracks Problem

Milly and Chocolates again
Tag(s):

Binary Search, Data Structures, Easy-Medium

Problem
Editorial
Analytics

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 Ci chocolates are there in ith the box. Description of index is given below :

Suppose there are A1, A2 … AN chocolates in 1st, 2nd… Nth boxes respectively. So, indexing of chocolates in 1st box will be from 1 to A1, similarly in 2nd box indexing will be A1 + 1 to A2 … and indexing in Nth box will be from AN-1 + 1 to AN.

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 Ci, the number of chocolates in ith 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 ≤ 105
  • 1 ≤ Ci ≤ 10
  • 1 ≤ ∑ Ci ≤ 106
  • 1 ≤ I ∑ Ci
SAMPLE INPUT
2
2 3
2
2
4
SAMPLE OUTPUT
1
2
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++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Amazon

Challenge Name

Amazon Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications