Goat II
Goat II
Problem Statement
Andy the goat is very hungry. Luckily, there is a line of n tufts of grass directly in front of him in a line. However, the i-th tuft of grass takes Ai seconds to eat.
Andy has q questions, each of the form "How many tufts of grass could I eat in Bi seconds?". Note that he must eat the tufts in the order given in the input.
Input
The first line of input will consist of two integers, n and q.
The second line of input will consist of n integers, the array A.
The third line of input will consist of q integers, each being the amount of tufts Andy is thinking about in one question.
Output
The output should consist of a single line of q integers, one for each question.
Constraints
For all test cases:
- 1≤n≤105
- 1≤q≤105
- 1≤A[i]≤103
- 1≤B[i]≤108
Sample Test Cases
Example 1
3 2
1 5 9
7 16
2 3
Explanation
In 7 seconds, Andy can eat the first two tufts of grass (takes 1+5=6 seconds).
In 16 seconds, Andy can eat all three tufts of grass (takes 1+5+9=15 seconds).
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.