#P2969. Song Query for Cows

    ID: 16227 Type: Default 1000ms 256MiB

Song Query for Cows

Song Query for Cows

Farmer John is teaching his cows to play a song that consists of \(N\) notes. The \(i\)-th note lasts for \(B_i\) beats. The cows begin playing at time 0, so note 1 is played from time 0 up to (but not including) time \(B_1\), note 2 from time \(B_1\) to time \(B_1+B_2\), and so on.

To ensure the cows are paying attention, FJ asks them \(Q\) queries of the form: "At time \(T\), which note should you be playing?" Your task is to answer each query. Note that the notes are 1-indexed.

inputFormat

The first line contains two integers \(N\) and \(Q\) separated by a space.

The second line contains \(N\) integers \(B_1, B_2, \ldots, B_N\) representing the duration (in beats) of each note.

The following \(Q\) lines each contain one integer \(T\), representing the query time.

outputFormat

For each query, output a single line with the note number that is being played at time \(T\).

sample

3 5
2 1 3
2
3
4
0
1
2

3 3 1 1

</p>